Skip to contentSkip to conversation

sparc: Update SPARC architecture to generic board init

RFC PATCH Superseded Francois Retief 2 participants 11 messages Oct 29, 2014 – Oct 30, 2014

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover sparc: Update SPARC architecture to generic board init

The SPARC architecture has not yet been upgraded to the new generic board init codebase. This patch series is an first attempt at that.

We currently only have access to one SPARC board (gr712rc-board) and would appreciate some help with testing. Other comments and suggestions are welcome. We also need some advice on what else needs to be done for the conversion to the generic board init code.

This series currently does not remove the old init code. That will be done in a later version of the series.

Francois Retief (9):
sparc: Add initr function for CMD_AMBAPP command
sparc: Initial work for generic board-init
sparc: Use microseconds instead of ticks for timeout
sparc: Major rewrite of the PROM generation code
sparc: Reworked LEON3 startup for generic board-init
sparc: Update all LEON3 boards to generic board-init
sparc: Make LEON serial drivers use readl/writel macros
sparc: Add MDIO support to GRETH driver
sparc: Add support for gr712rc-board

 arch/sparc/Kconfig                          |    4 +
 arch/sparc/config.mk                        |    3 +
 arch/sparc/cpu/leon2/Makefile               |    2 +-
 arch/sparc/cpu/leon2/prom.c                 | 1030 ---------------------------
 arch/sparc/cpu/leon2/serial.c               |  121 ++--
 arch/sparc/cpu/leon3/Makefile               |    5 +-
 arch/sparc/cpu/leon3/cpu.c                  |   14 +
 arch/sparc/cpu/leon3/cpu_init.c             |   57 ++
 arch/sparc/cpu/leon3/interrupts.c           |   14 +
 arch/sparc/cpu/leon3/prom.c                 |    2 +-
 arch/sparc/cpu/leon3/serial.c               |   93 +--
 arch/sparc/cpu/leon3/start.S                |  436 ++++++------
 arch/sparc/include/asm/config.h             |    1 +
 arch/sparc/include/asm/io.h                 |   43 +-
 arch/sparc/include/asm/machines.h           |    4 +-
 arch/sparc/include/asm/u-boot.h             |    7 +
 arch/sparc/lib/Makefile                     |    9 +-
 arch/sparc/lib/bootm.c                      |   81 ++-
 arch/sparc/lib/interrupts.c                 |    7 +
 arch/sparc/lib/prom-no.c                    |  319 +++++++++
 arch/sparc/lib/prom-no.h                    |   40 ++
 arch/sparc/lib/prom.c                       |  960 +++++++++++++++++++++++++
 arch/sparc/lib/srmmu.c                      |   90 +++
 arch/sparc/lib/time.c                       |    5 +
 board/gaisler/gr712rc_board/Kconfig         |   19 +
 board/gaisler/gr712rc_board/MAINTAINERS     |    6 +
 board/gaisler/gr712rc_board/Makefile        |    8 +
 board/gaisler/gr712rc_board/README          |   24 +
 board/gaisler/gr712rc_board/config.mk       |   15 +
 board/gaisler/gr712rc_board/gr712rc_board.c |  110 +++
 common/board_f.c                            |    2 +-
 common/board_r.c                            |   21 +
 common/cmd_ambapp.c                         |   18 +-
 common/cmd_bdinfo.c                         |    4 +
 configs/gr712rc_board_defconfig             |    2 +
 drivers/net/greth.c                         |   59 +-
 include/ambapp.h                            |   27 +-
 include/configs/gr712rc_board.h             |  366 ++++++++++
 include/configs/gr_cpci_ax2000.h            |    2 +
 include/configs/gr_ep2s60.h                 |    2 +
 include/configs/gr_xc3s_1500.h              |    2 +
 include/configs/grsim.h                     |    2 +
 42 files changed, 2634 insertions(+), 1402 deletions(-)
 delete mode 100644 arch/sparc/cpu/leon2/prom.c
 create mode 100644 arch/sparc/lib/prom-no.c
 create mode 100644 arch/sparc/lib/prom-no.h
 create mode 100644 arch/sparc/lib/prom.c
 create mode 100644 arch/sparc/lib/srmmu.c
 create mode 100644 board/gaisler/gr712rc_board/Kconfig
 create mode 100644 board/gaisler/gr712rc_board/MAINTAINERS
 create mode 100644 board/gaisler/gr712rc_board/Makefile
 create mode 100644 board/gaisler/gr712rc_board/README
 create mode 100644 board/gaisler/gr712rc_board/config.mk
 create mode 100644 board/gaisler/gr712rc_board/gr712rc_board.c
 create mode 100644 configs/gr712rc_board_defconfig
 create mode 100644 include/configs/gr712rc_board.h

--
1.9.3

________________________________
Disclaimer and confidentiality note ? refer to our website for further details: www.spaceteq.co.za <http://www.spaceteq.co.za/home/emaildisclaimer/>

#1 lore raw

RFC PATCH 1/9 sparc: Add initr function for CMD_AMBAPP command

Add an initr function in board_r.c file for the AMBA PnP command.

---

 common/board_r.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
common/board_r.c +21 -0
index 7c33900..6d6c7e8 100644
@@ -45,6 +45,9 @@
 #include <stdio_dev.h>
 #include <trace.h>
 #include <watchdog.h>
+#ifdef CONFIG_CMD_AMBAPP
+#include <ambapp.h>
+#endif
 #ifdef CONFIG_ADDR_MAP
 #include <asm/mmu.h>
 #endif
@@ -566,6 +569,18 @@ static int initr_status_led(void)
 }
 #endif
 
+#if defined(CONFIG_CMD_AMBAPP) && defined(CONFIG_SYS_AMBAPP_PRINT_ON_STARTUP)
+extern int do_ambapp_print(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]);
+
+static int initr_ambapp_print(void)
+{
+       puts("AMBA:\n");
+       do_ambapp_print(NULL, 0, 0, NULL);
+
+       return 0;
+}
+#endif
+
 #if defined(CONFIG_CMD_SCSI)
 static int initr_scsi(void)
 {
@@ -857,6 +872,12 @@ init_fnc_t init_sequence_r[] = {
 #ifdef CONFIG_BOARD_LATE_INIT
        board_late_init,
 #endif
+#if defined(CONFIG_CMD_AMBAPP)
+       ambapp_init_reloc,
+#if defined(CONFIG_SYS_AMBAPP_PRINT_ON_STARTUP)
+       initr_ambapp_print,
+#endif
+#endif
 #ifdef CONFIG_CMD_SCSI
        INIT_FUNC_WATCHDOG_RESET
        initr_scsi,

--
1.9.3

________________________________
Disclaimer and confidentiality note ? refer to our website for further details: www.spaceteq.co.za <http://www.spaceteq.co.za/home/emaildisclaimer/>

#2 lore raw

RFC PATCH 2/9 sparc: Initial work for generic board-init

In reply to Francois Retief

Initial work in preperation for generic board init for the SPARC architecture.

---

 arch/sparc/config.mk              |  3 +++
 arch/sparc/cpu/leon3/cpu.c        | 14 ++++++++++
 arch/sparc/cpu/leon3/cpu_init.c   | 57 +++++++++++++++++++++++++++++++++++++++
 arch/sparc/cpu/leon3/interrupts.c | 14 ++++++++++
 arch/sparc/include/asm/config.h   |  1 +
 arch/sparc/include/asm/u-boot.h   |  7 +++++
 arch/sparc/lib/Makefile           |  7 ++++-
 arch/sparc/lib/interrupts.c       |  7 +++++
 arch/sparc/lib/time.c             |  5 ++++
 common/board_f.c                  |  2 +-
 10 files changed, 115 insertions(+), 2 deletions(-)
arch/sparc/config.mk +3 -0
index 196d28a..b8ba4be 100644
@@ -15,3 +15,6 @@ CONFIG_STANDALONE_LOAD_ADDR ?= 0x00000000 -L $(gcclibdir) \
                               -T $(srctree)/examples/standalone/sparc.lds
 
 PLATFORM_CPPFLAGS += -D__sparc__
+
+# Support generic board on SPARC
+__HAVE_ARCH_GENERIC_BOARD := y
arch/sparc/cpu/leon3/cpu.c +14 -0
index 8ab3150..088c8ac 100644
@@ -18,6 +18,8 @@ DECLARE_GLOBAL_DATA_PTR;
 
 extern void _reset_reloc(void);
 
+#ifndef CONFIG_SYS_GENERIC_BOARD
+
 int checkcpu(void)
 {
        /* check LEON version here */
@@ -25,6 +27,18 @@ int checkcpu(void)
        return 0;
 }
 
+#endif
+
+#ifdef CONFIG_DISPLAY_CPUINFO
+
+int print_cpuinfo(void)
+{
+       printf("CPU:   LEON3\n");
+       return 0;
+}
+
+#endif
+
 /* ------------------------------------------------------------------------- */
 
 void cpu_reset(void)
arch/sparc/cpu/leon3/cpu_init.c +57 -0

100 lines not on this page · raw message

arch/sparc/cpu/leon3/interrupts.c +14 -0
index a834aa0..20e295c 100644
@@ -116,12 +116,24 @@ void leon3_force_int(int irq)
 
 int interrupt_init_cpu(void)
 {
+#ifdef CONFIG_SYS_GENERIC_BOARD
+       ambapp_apbdev apbdev;
+
+       /*
+        * Find AMBA APB IRQMP Controller,
+        * When we come so far we know there is a IRQMP available
+        */
+       ambapp_apb_first(VENDOR_GAISLER, GAISLER_IRQMP, &apbdev);
+       irqmp = (ambapp_dev_irqmp *) apbdev.address;
+#endif
 
        return (0);
 }
 
 /****************************************************************************/
 
+#ifndef CONFIG_SYS_GENERIC_BOARD
+
 /* Handle Timer 0 IRQ */
 void timer_interrupt_cpu(void *arg)
 {
@@ -132,6 +144,8 @@ void timer_interrupt_cpu(void *arg)
        return;
 }
 
+#endif
+
 /****************************************************************************/
 
 /*
arch/sparc/include/asm/config.h +1 -0
index fd0b551..66cde58 100644
@@ -8,6 +8,7 @@
 #define _ASM_CONFIG_H_
 
 #define CONFIG_NEEDS_MANUAL_RELOC
+#define CONFIG_SYS_GENERIC_GLOBAL_DATA
 
 #define CONFIG_LMB
 #define CONFIG_SYS_BOOT_RAMDISK_HIGH
arch/sparc/include/asm/u-boot.h +7 -0
index 5f12e58..4c4b5f2 100644
@@ -17,6 +17,11 @@
 #ifndef __U_BOOT_H__
 #define __U_BOOT_H__
 
+#ifdef CONFIG_SYS_GENERIC_BOARD
+/* Use the generic board which requires a unified bd_info */
+#include <asm-generic/u-boot.h>
+#else
+
 /*
  * Currently, this Board information is not passed to
  * Linux kernel from U-Boot, but may be passed to other
@@ -44,6 +49,8 @@ typedef struct bd_info {
 
 #endif                         /* __ASSEMBLY__ */
 
+#endif /* !CONFIG_SYS_GENERIC_BOARD */
+
 /* For image.h:image_check_target_arch() */
 #define IH_ARCH_DEFAULT IH_ARCH_SPARC
 
arch/sparc/lib/Makefile +6 -1
index e69b9ba..84c3ac2 100644
@@ -5,5 +5,10 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-obj-y  = board.o cache.o interrupts.o time.o
+obj-y  = cache.o interrupts.o time.o
+
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
+
+ifndef CONFIG_SYS_GENERIC_BOARD
+obj-y  += board.o
+endif
arch/sparc/lib/interrupts.c +7 -0
index b7c3993..93479a9 100644
@@ -17,8 +17,11 @@
 
 /* Implemented by SPARC CPUs */
 extern int interrupt_init_cpu(void);
+
+#ifndef CONFIG_SYS_GENERIC_BOARD
 extern void timer_interrupt_cpu(void *arg);
 extern int timer_interrupt_init_cpu(void);
+#endif
 
 int intLock(void)
 {
@@ -60,6 +63,8 @@ int interrupt_init(void)
        return ret;
 }
 
+#ifndef CONFIG_SYS_GENERIC_BOARD
+
 /* timer interrupt/overflow counter */
 static volatile ulong timestamp = 0;
 
@@ -94,3 +99,5 @@ void timer_interrupt_init(void)
        /* register interrupt handler for timer */
        irq_install_handler(irq, (void (*)(void *))timer_interrupt, NULL);
 }
+
+#endif
arch/sparc/lib/time.c +5 -0
index 50a09ad..257b41b 100644
@@ -10,6 +10,8 @@
 
 #include <common.h>
 
+#ifndef CONFIG_SYS_GENERIC_BOARD
+
 /* Implemented by SPARC CPUs */
 extern void cpu_wait_ticks(unsigned long ticks);
 extern unsigned long cpu_usec2ticks(unsigned long usec);
@@ -32,6 +34,7 @@ unsigned long usec2ticks(unsigned long usec)
 
 /* ------------------------------------------------------------------------- */
 
+
 /*
  * We implement the delay by converting the delay (the number of
  * microseconds to wait) into a number of time base ticks; then we
@@ -59,4 +62,6 @@ int init_timebase(void)
        return (0);
 }
 
+#endif
+
 /* ------------------------------------------------------------------------- */
common/board_f.c +1 -1
index b5bebc9..c97a1f8 100644
@@ -842,7 +842,7 @@ static init_fnc_t init_sequence_f[] = {
        /* TODO: can we rename this to timer_init()? */
        init_timebase,
 #endif
-#if defined(CONFIG_ARM) || defined(CONFIG_MIPS) || defined(CONFIG_BLACKFIN)
+#if defined(CONFIG_ARM) || defined(CONFIG_MIPS) || defined(CONFIG_BLACKFIN) || defined(CONFIG_SPARC)
        timer_init,             /* initialize timer */
 #endif
 #ifdef CONFIG_SYS_ALLOC_DPRAM

--
1.9.3

________________________________
Disclaimer and confidentiality note ? refer to our website for further details: www.spaceteq.co.za <http://www.spaceteq.co.za/home/emaildisclaimer/>

#3 lore raw

RFC PATCH 3/9 sparc: Use microseconds instead of ticks for timeout

In reply to Francois Retief

We now use the generic delay method which specifies the timeout as microseconds instead of ticks.

---

 drivers/net/greth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/greth.c +1 -1
index c817af4..7784684 100644
@@ -237,7 +237,7 @@ int greth_init_phy(greth_priv * dev, bd_t * bis)
        debug("GRETH PHY ADDRESS: %d\n", phyaddr);
 
        /* X msecs to ticks */
-       timeout = usec2ticks(GRETH_PHY_TIMEOUT_MS * 1000);
+       timeout = GRETH_PHY_TIMEOUT_MS * 1000;
 
        /* Get system timer0 current value
         * Total timeout is 5s

--
1.9.3

________________________________
Disclaimer and confidentiality note ? refer to our website for further details: www.spaceteq.co.za <http://www.spaceteq.co.za/home/emaildisclaimer/>

#4 lore raw

RFC PATCH 4/9 sparc: Major rewrite of the PROM generation code

In reply to Francois Retief

Rewrote the PROM generation code to dynamically build the PROM from the AMBA PnP data on the LEON3. Also combined the LEON2/LEON3 code into one file and moved it to the arch/sparc/lib folder. The new code generates the PROM data rather than having it embedded as data and copying it over. The algorithm is also optimized to reduce the size of the resulting PROM data, e.g. pointers is encoded into 16-bit values and duplicate names point to the same copy of the string.

Also added a few more AMBA vendor/device ID pairs to cmd_ambapp.c.

Refactored the SRMMU handling code into a seperate file. Added a function to build the default page tables instead of adding them at compile time.

The bootm.c file were also updated to search for the kernel header, instead of being a hard coded offset.

This code has been tested against a Linux v3.10.20 kernel.

---

 arch/sparc/cpu/leon2/Makefile     |    2 +-
 arch/sparc/cpu/leon2/prom.c       | 1030 -------------------------------------
 arch/sparc/cpu/leon3/Makefile     |    5 +-
 arch/sparc/cpu/leon3/prom.c       |    2 +-
 arch/sparc/include/asm/machines.h |    4 +-
 arch/sparc/lib/Makefile           |    4 +-
 arch/sparc/lib/bootm.c            |   81 +--
 arch/sparc/lib/prom-no.c          |  319 ++++++++++++
 arch/sparc/lib/prom-no.h          |   40 ++
 arch/sparc/lib/prom.c             |  960 ++++++++++++++++++++++++++++++++++
 arch/sparc/lib/srmmu.c            |   90 ++++
 common/cmd_ambapp.c               |   18 +-
 include/ambapp.h                  |   27 +-
 13 files changed, 1509 insertions(+), 1073 deletions(-)
 delete mode 100644 arch/sparc/cpu/leon2/prom.c
 create mode 100644 arch/sparc/lib/prom-no.c
 create mode 100644 arch/sparc/lib/prom-no.h
 create mode 100644 arch/sparc/lib/prom.c
 create mode 100644 arch/sparc/lib/srmmu.c
arch/sparc/cpu/leon2/Makefile +1 -1
index 8c95ca5..1a2dae6 100644
@@ -6,4 +6,4 @@
 #
 
 extra-y        = start.o
-obj-y  = cpu_init.o serial.o cpu.o interrupts.o prom.o
+obj-y  = cpu_init.o serial.o cpu.o interrupts.o
arch/sparc/cpu/leon2/prom.c deleted +0 -1030

1,030 lines not on this page · raw message

arch/sparc/cpu/leon3/Makefile +4 -1
index 4f13ec3..0131f22 100644
@@ -6,4 +6,7 @@
 #
 
 extra-y        = start.o
-obj-y  = cpu_init.o serial.o cpu.o ambapp.o interrupts.o prom.o usb_uhci.o
+
+obj-y  = cpu_init.o serial.o cpu.o ambapp.o interrupts.o
+
+obj-$(CONFIG_USB_UHCI) += usb_uhci.o
arch/sparc/cpu/leon3/prom.c +1 -1
index b83776b..e9e9a71 100644
@@ -695,7 +695,7 @@ static void PROM_TEXT leon_reboot_physical(char *bcommand)
        srmmu_set_mmureg(0);
 
        /* Hardcoded start address */
-       reset = CONFIG_SYS_MONITOR_BASE;
+       reset = (void*)CONFIG_SYS_MONITOR_BASE;
 
        /* flush data cache */
        sparc_dcache_flush_all();
arch/sparc/include/asm/machines.h +3 -1
index e209f3f..1abbd13 100644
@@ -37,7 +37,7 @@ extern struct Sun_Machine_Models Sun_Machines[NUM_SUN_MACHINES];
 
 #define SM_ARCH_MASK  0xf0
 #define SM_SUN4       0x20
-#define  M_LEON2      0x30
+#define  M_LEON       0x30
 #define SM_SUN4C      0x50
 #define SM_SUN4M      0x70
 #define SM_SUN4M_OBP  0x80
@@ -51,6 +51,8 @@ extern struct Sun_Machine_Models Sun_Machines[NUM_SUN_MACHINES];
 
 /* Leon machines */
 #define M_LEON2_SOC   0x01     /* Leon2 SoC */
+#define M_LEON3_SOC   0x02     /* Leon3 SoC */
+#define M_LEON4_SOC   0x03     /* Leon4 SoC */
 
 /* Sun4c machines                Full Name              - PROM NAME */
 #define SM_4C_SS1     0x01     /* Sun4c SparcStation 1   - Sun 4/60  */
arch/sparc/lib/Makefile +3 -1
index 84c3ac2..bf2de51 100644
@@ -5,7 +5,9 @@
 # SPDX-License-Identifier:     GPL-2.0+
 #
 
-obj-y  = cache.o interrupts.o time.o
+obj-y  = cache.o interrupts.o time.o srmmu.o
+
+obj-y  += prom.o prom-no.o
 
 obj-$(CONFIG_CMD_BOOTM) += bootm.o
 
arch/sparc/lib/bootm.c +50 -31

132 lines not on this page · raw message

arch/sparc/lib/prom-no.c new file +319 -0

319 lines not on this page · raw message

arch/sparc/lib/prom-no.h new file +40 -0
new file mode 100644
index 0000000..ef369a1
@@ -0,0 +1,40 @@
+#ifndef __PROM_NO_H__
+#define __PROM_NO_H__
+
+#include <ambapp.h>
+
+struct prom_prop {
+       short name;
+       short length;
+       void *value;
+};
+
+struct prom_node {
+       short next;
+       short child;
+       int num_props;
+       struct prom_prop props[0];
+};
+
+struct prom_priv {
+       struct prom_node *root_node;
+       ambapp_dev_apbuart *uart;
+};
+
+/* structure that holds entry pointers */
+extern struct prom_priv __prom_entry;
+
+extern int prom_no_nextnode(int);
+extern int prom_no_getchild(int);
+extern char *prom_no_nextprop(int, char *);
+extern int prom_no_proplen(int, char *);
+extern int prom_no_getprop(int, char *, char *);
+extern int prom_no_setprop(int, char *, char *, int);
+
+extern int prom_nb_getchar(void);
+extern int prom_nb_putchar(int);
+
+extern void prom_reboot(char *);
+extern void prom_halt(void);
+
+#endif /* __PROM_NO_H__ */
arch/sparc/lib/prom.c new file +960 -0

960 lines not on this page · raw message

arch/sparc/lib/srmmu.c new file +90 -0

90 lines not on this page · raw message

common/cmd_ambapp.c +17 -1
index 2a1995a..aa32234 100644
@@ -50,7 +50,7 @@ static ambapp_device_name gaisler_devices[] = {
        {GAISLER_PCITRACE, "GAISLER_PCITRACE"},
        {GAISLER_AHBTRACE, "GAISLER_AHBTRACE"},
        {GAISLER_ETHDSU, "GAISLER_ETHDSU"},
-       {GAISLER_PIOPORT, "GAISLER_PIOPORT"},
+       {GAISLER_GPIO, "GAISLER_GPIO"},
        {GAISLER_AHBJTAG, "GAISLER_AHBJTAG"},
        {GAISLER_ATACTRL, "GAISLER_ATACTRL"},
        {GAISLER_VGA, "GAISLER_VGA"},
@@ -62,9 +62,25 @@ static ambapp_device_name gaisler_devices[] = {
        {GAISLER_SPW2, "GAISLER_SPW2"},
        {GAISLER_EHCI, "GAISLER_EHCI"},
        {GAISLER_UHCI, "GAISLER_UHCI"},
+       {GAISLER_I2CMST, "GAISLER_I2CMST"},
+       {GAISLER_SPICTRL, "GAISLER_SPICTRL"},
        {GAISLER_AHBSTAT, "GAISLER_AHBSTAT"},
        {GAISLER_DDR2SPA, "GAISLER_DDR2SPA"},
        {GAISLER_DDRSPA, "GAISLER_DDRSPA"},
+       {GAISLER_LEON3FT, "GAISLER_LEON3FT"},
+       {GAISLER_FTMCTRL, "GAISLER_FTMCTRL"},
+       {GAISLER_B1553BRM, "GAISLER_B1553BRM"},
+       {GAISLER_FTAHBRAM, "GAISLER_FTAHBRAM"},
+       {GAISLER_CANAHB, "GAISLER_CANAHB"},
+       {GAISLER_SATCAN, "GAISLER_SATCAN"},
+       {GAISLER_CANMUX, "GAISLER_CANMUX"},
+       {GAISLER_SLINK, "GAISLER_SLINK"},
+       {GAISLER_GRTM, "GAISLER_GRTM"},
+       {GAISLER_GRTC, "GAISLER_GRTC"},
+       {GAISLER_GRTIMER, "GAISLER_GRTIMER"},
+       {GAISLER_CLKGATE, "GAISLER_CLKGATE"},
+       {GAISLER_GPREG, "GAISLER_GPREG"},
+       {GAISLER_ASCS, "GAISLER_ASCS"},
        {0, NULL}
 };
 
include/ambapp.h +21 -6
index 405637d..dfd6fa9 100644
@@ -62,20 +62,35 @@
 #define GAISLER_PCIDMA   0x016
 #define GAISLER_AHBTRACE 0x017
 #define GAISLER_ETHDSU   0x018
-#define GAISLER_PIOPORT  0x01A
-#define GAISLER_AHBJTAG  0x01c
-#define GAISLER_SPW      0x01f
-#define GAISLER_ATACTRL  0x024
-#define GAISLER_VGA      0x061
-#define GAISLER_KBD      0X060
+#define GAISLER_CANAHB   0x019
+#define GAISLER_GPIO     0x01A
+#define GAISLER_AHBJTAG  0x01C
 #define GAISLER_ETHMAC   0x01D
+#define GAISLER_SPW      0x01F
+#define GAISLER_ATACTRL  0x024
 #define GAISLER_DDRSPA   0x025
 #define GAISLER_EHCI     0x026
 #define GAISLER_UHCI     0x027
+#define GAISLER_I2CMST   0x028
 #define GAISLER_SPW2     0x029
+#define GAISLER_CLKGATE  0x02C
+#define GAISLER_SPICTRL  0x02D
 #define GAISLER_DDR2SPA  0x02E
+#define GAISLER_SLINK    0x02F
+#define GAISLER_GRTM     0x030
+#define GAISLER_GRTC     0x031
+#define GAISLER_GRTIMER  0x038
+#define GAISLER_ASCS     0x043
+#define GAISLER_FTAHBRAM 0x050
 #define GAISLER_AHBSTAT  0x052
+#define GAISLER_LEON3FT  0x053
 #define GAISLER_FTMCTRL  0x054
+#define GAISLER_KBD      0x060
+#define GAISLER_VGA      0x061
+#define GAISLER_B1553BRM 0x072
+#define GAISLER_SATCAN   0x080
+#define GAISLER_CANMUX   0x081
+#define GAISLER_GPREG    0x087
 
 #define GAISLER_L2TIME   0xffd /* internal device: leon2 timer */
 #define GAISLER_L2C      0xffe /* internal device: leon2compat */

--
1.9.3

________________________________
Disclaimer and confidentiality note ? refer to our website for further details: www.spaceteq.co.za <http://www.spaceteq.co.za/home/emaildisclaimer/>

#5 lore raw

RFC PATCH 5/9 sparc: Reworked LEON3 startup for generic board-init

In reply to Francois Retief

Reworked the LEON3 startup code to call board_init_f function at startup. Also implemented the relocate_code function in assembly to relocate the monitor and setup the stack pointer before calling board_init_r.

---

 arch/sparc/cpu/leon3/start.S | 436 +++++++++++++++++++++++--------------------
 1 file changed, 236 insertions(+), 200 deletions(-)
arch/sparc/cpu/leon3/start.S +236 -200
index cf897f6..198f342c 100644
@@ -179,15 +179,6 @@ _trap_table:
        SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;     ! f4-f7
        SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;     ! f8-fb
        SOFT_TRAP; SOFT_TRAP; SOFT_TRAP; SOFT_TRAP;     ! fc-ff
-/*
- * Version string
- */
-
-       .data
-       .extern leon3_snooping_avail
-       .globl  version_string
-version_string:
-       .ascii U_BOOT_VERSION_STRING, "\0"
 
        .section        ".text"
        .align 4
@@ -232,151 +223,237 @@ clear_window:
        bge     clear_window
        save
 
-wininit:
+wiminit:
        set     WIM_INIT, %g3
        mov     %g3, %wim
 
-stackp:
+stack_init:
        set     CONFIG_SYS_INIT_SP_OFFSET, %fp
        andn    %fp, 0x0f, %fp
        sub     %fp, 64, %sp
 
+tbr_init:
+       set     CONFIG_SYS_TEXT_BASE, %g2
+       wr      %g0, %g2, %tbr
+       nop
+       nop
+       nop
+
+#if 1 /* can't do this here, if we run from flash, we will be writing to flash! */
+clr_bss:
+       call 1f ! Use call to get hold of address for data table
+        nop
+       /* addresses of BSS segment */
+       .word   __bss_start     ! 0x08
+       .word   __bss_end       ! 0x0C
+1:     ld      [%o7+0x08], %g2         ! __bss_start
+       ld      [%o7+0x0C], %g3         ! __bss_stop
+       /* clearing 16byte a time ==> linker script need to align to 16 byte offset */
+       clr     %g1     /* std %g0 uses g0 and g1 */
+2:     std     %g0, [%g2]
+       std     %g0, [%g2+8]
+       inc     16, %g2                 ! ptr += 16
+       cmp     %g2, %g3
+       bcs     2b                      ! while (ptr < end)
+        nop
+#endif
+
 cpu_init_unreloc:
        call    cpu_init_f
-       nop
+        nop
 
-/* un relocated start address of monitor */
-#define TEXT_START _text
-
-/* un relocated end address of monitor */
-#define DATA_END __init_end
-
-reloc:
-       set     TEXT_START,%g2
-       set     DATA_END,%g3
-       set     CONFIG_SYS_RELOC_MONITOR_BASE,%g4
-reloc_loop:
-       ldd     [%g2],%l0
-       ldd     [%g2+8],%l2
-       std     %l0,[%g4]
-       std     %l2,[%g4+8]
-       inc     16,%g2
-       subcc   %g3,%g2,%g0
-       bne     reloc_loop
-       inc     16,%g4
-
-       clr     %l0
-       clr     %l1
-       clr     %l2
-       clr     %l3
-       clr     %g2
+board_init_unreloc:
+       call    board_init_f
+        clr    %o0                     ! boot_flags
+
+dead:
+       mov     1, %g1                  ! For GRMON2 to exit normally
+       ta 0                            ! if call returns.. (unlikely)
+        nop
+
+!-------------------------------------------------------------------------------
 
-/* register g4 contain address to start
- * This means that BSS must be directly after data and code segments
+/*
+ * void relocate_code (addr_sp, gd, addr_moni)
  *
- * g3 is length of bss = (__bss_end-__bss_start)
+ * This "function" does not return, instead it continues in RAM
+ * after relocating the monitor code.
  *
+ * %i0 = Relocated stack pointer
+ * %i1 = Relocated global data pointer
+ * %i2 = Relocated text pointer
  */
-
-clr_bss:
-/* clear bss area (the relocated) */
-       set     __bss_start,%g2
-       set     __bss_end,%g3
-       sub     %g3,%g2,%g3
-       add     %g3,%g4,%g3
-       clr     %g1     /* std %g0 uses g0 and g1 */
-/* clearing 16byte a time ==> linker script need to align to 16 byte offset */
-clr_bss_16:
-       std     %g0,[%g4]
-       std     %g0,[%g4+8]
-       inc     16,%g4
-       cmp     %g3,%g4
-       bne     clr_bss_16
+       .globl  relocate_code
+       .type   relocate_code, #function
+relocate_code:
+       call 1f ! Use call to get hold of the actual address our data table
+        nop
+       /* final function to call */
+       .word   board_init_r    ! 0x00
+       /* start address of text segment */
+       .word   _text           ! 0x04
+       /* addresses of BSS segment */
+       .word   __bss_start     ! 0x08
+       .word   __bss_end       ! 0x0C
+       /* addresses of GOT segment */
+       .word   __got_start     ! 0x10
+       .word   __got_end       ! 0x14
+1:
+       add     %o7, 0x08, %g5          ! data table address
+
+       /* disable traps */
+!      mov     %psr, %l0
+!      and     %l0, 0xFFFFFFDF, %l0
+!      mov     %l0, %psr
+
+ ! %o0 = Relocated stack pointer
+ ! %o1 = Relocated global data pointer
+ ! %o2 = Relocated text pointer
+ ! %o7 = Actual address of relocate_code
+
+ ! %g5 = Data table address
+ ! %g6 = Relocation offset
+
+_reloc:
+       ld      [%g5+0x04], %g2         ! _text
+       sub     %o2, %g2, %g6           ! relocation offset
+       ld      [%g5+0x0C], %g3         ! __bss_stop
+       mov     %o2, %g4                ! relocation pointer
+       /* copy text & bss to relocated address */
+10:    ldd     [%g2], %l0
+       ldd     [%g2+8], %l2
+       std     %l0, [%g4]
+       std     %l2, [%g4+8]
+       inc     16, %g2
+       cmp     %g2, %g3
+       bcs     10b                     ! while (ptr < end)
+        inc    16, %g4
+
+       /* add offsets to GOT table */
+_fixup_got:
+       ld      [%g5+0x10], %g4         ! __got_start
+       add     %g4, %g6, %g4
+       ld      [%g5+0x14], %g3         ! __got_end
+       add     %g3, %g6, %g3
+30:    ld      [%g4], %l0
+#ifdef CONFIG_RELOC_GOT_SKIP_NULL
+       cmp     %l0, 0
+       be      32f
+#endif
+       add     %l0, %g6, %l0           ! relocate GOT pointer
+       st      %l0, [%g4]
+32:    inc     4, %g4
+       cmp     %g4, %g3
+       bcs     30b                     ! while (ptr < end)
+        nop
+
+ ! %o0 = stack pointer (relocated)
+ ! %o1 = global data pointer (relocated)
+ ! %o2 = text pointer (relocated)
+
+ ! %g5 = data table address
+ ! %g6 = relocation offset
+
+       /* Trap table has been moved, tell CPU about new trap table address */
+_update_trap_table_address:
+       wr      %g0, %o2, %tbr
+       nop
+       nop
        nop
 
-/* add offsets to GOT table */
-fixup_got:
-       set     __got_start,%g4
-       set     __got_end,%g3
+_update_stack_pointers:
+       mov     %o0, %fp
+       andn    %fp, 0x0f, %fp  ! align to 16 bytes
+       add     %fp, -64, %fp   ! make space for a window push
+       mov     %fp, %sp        ! setup stack pointer
+
+_jump_board_init_r:
+       mov     %o1, %o0        ! relocated global data pointer
+       mov     %o2, %o1        ! relocated text pointer
+
+       ld      [%g5+0x00], %o3 ! board_init_r
+       add     %o3, %g6, %o3   ! relocate address
+       call    %o3
+        nop
+
+       mov     1, %g1          ! should not reach this point
+       ta 0
+        nop
+
+!-------------------------------------------------------------------------------
+
 /*
- * new got offset = (old GOT-PTR (read with ld) -
- *   CONFIG_SYS_RELOC_MONITOR_BASE(from define) ) +
- *   Destination Address (from define)
+ * Window overflow trap handler
  */
-       set     CONFIG_SYS_RELOC_MONITOR_BASE,%g2
-       set     TEXT_START, %g1
-       add     %g4,%g2,%g4
-       sub     %g4,%g1,%g4
-       add     %g3,%g2,%g3
-       sub     %g3,%g1,%g3
-       sub     %g2,%g1,%g2     ! prepare register with (new base address) -
-                               !  (old base address)
-got_loop:
-       ld      [%g4],%l0       ! load old GOT-PTR
-       add     %l0,%g2,%l0     ! increase with (new base address) -
-                               !  (old base)
-       st      %l0,[%g4]
-       inc     4,%g4
-       cmp     %g3,%g4
-       bne     got_loop
+       .global _window_overflow
+_window_overflow:
+       mov     %wim, %l3               ! Calculate next WIM
+       sll     %l3, (CONFIG_SYS_SPARC_NWINDOWS-1) , %l4
+       srl     %l3, 1, %l3
+       or      %l3, %l4, %l3
+
+       mov     %g0, %wim               ! Disable WIM traps
+       nop
+       nop
        nop
 
-prom_relocate:
-       set     __prom_start, %g2
-       set     __prom_end, %g3
-       set     CONFIG_SYS_PROM_OFFSET, %g4
-
-prom_relocate_loop:
-       ldd     [%g2],%l0
-       ldd     [%g2+8],%l2
-       std     %l0,[%g4]
-       std     %l2,[%g4+8]
-       inc     16,%g2
-       subcc   %g3,%g2,%g0
-       bne     prom_relocate_loop
-       inc     16,%g4
-
-/* Trap table has been moved, lets tell CPU about
- * the new trap table address
- */
+       save                            ! Get into window to be saved
 
-       set     CONFIG_SYS_RELOC_MONITOR_BASE, %g2
-       wr      %g0, %g2, %tbr
+       std     %l0, [%sp +  0]         ! Save window to the stack
+       std     %l2, [%sp +  8]
+       std     %l4, [%sp + 16]
+       std     %l6, [%sp + 24]
+       std     %i0, [%sp + 32]
+       std     %i2, [%sp + 40]
+       std     %i4, [%sp + 48]
+       std     %i6, [%sp + 56]
+
+       restore                         ! Go back to trap window
+
+       mov     %l3, %wim               ! Set new WIM trap
        nop
        nop
        nop
 
-/* If CACHE snooping is available in hardware the
- * variable leon3_snooping_avail will be set to
- * 0x800000 else 0.
+       jmp     %l1                     ! Re-execute save
+        rett   %l2
+
+!-------------------------------------------------------------------------------
+
+/*
+ * Window underflow trap handler
  */
-snoop_detect:
-       sethi   %hi(0x00800000), %o0
-       lda     [%g0] 2, %o1
-       and     %o0, %o1, %o0
-       sethi   %hi(leon3_snooping_avail+CONFIG_SYS_RELOC_MONITOR_BASE-CONFIG_SYS_TEXT_BASE), %o1
-       st      %o0, [%lo(leon3_snooping_avail+CONFIG_SYS_RELOC_MONITOR_BASE-CONFIG_SYS_TEXT_BASE)+%o1]
-
-/*     call    relocate*/
+       .global  _window_underflow
+_window_underflow:
+       mov  %wim, %l3                  ! Calculate next WIM
+       srl  %l3, (CONFIG_SYS_SPARC_NWINDOWS-1), %l4
+       sll  %l3, 1, %l3
+       or   %l3, %l4, %l3
+
+       mov  %l3, %wim                  ! set new value of window
+       nop
+       nop
        nop
-/* Call relocated init functions */
-jump:
-       set     cpu_init_f2,%o1
-       set     CONFIG_SYS_RELOC_MONITOR_BASE,%o2
-       add     %o1,%o2,%o1
-       sub     %o1,%g1,%o1
-       call    %o1
-       clr     %o0
 
-       set     board_init_f,%o1
-       set     CONFIG_SYS_RELOC_MONITOR_BASE,%o2
-       add     %o1,%o2,%o1
-       sub     %o1,%g1,%o1
-       call    %o1
-       clr     %o0
+       restore                         ! Two restores to get into the
+       restore                         ! window to restore
 
-dead:  ta 0                            ! if call returns...
-       nop
+       ldd     [%sp +  0], %l0         ! Restore window from the stack
+       ldd     [%sp +  8], %l2
+       ldd     [%sp + 16], %l4
+       ldd     [%sp + 24], %l6
+       ldd     [%sp + 32], %i0
+       ldd     [%sp + 40], %i2
+       ldd     [%sp + 48], %i4
+       ldd     [%sp + 56], %i6
+
+       save                            ! Get back to the trap window
+       save
+
+       jmp     %l1                     ! Re-execute restore
+        rett   %l2
+
+!-------------------------------------------------------------------------------
 
 /* Interrupt handler caller,
  * reg L7: interrupt number
@@ -386,7 +463,25 @@ dead:      ta 0                            ! if call returns...
  * reg L3: wim
  */
 _irq_entry:
-       SAVE_ALL
+       mov     %o7, %l5                ! save original %o7
+       call    1f
+        ld     [%o7+0x08], %l4         ! trap_setup
+       .word   trap_setup      ! 0x08
+#ifdef CONFIG_SYS_GENERIC_BOARD
+       .word   _irq_entry      ! 0x0c
+       !SAVE_ALL
+1:
+       ld      [%o7+0x0C], %l6         ! _irq_entry
+       sub     %o7, %l6, %l6           ! relocation offset (+4)
+       sub     %l6, 4, %l6             ! relocation offset
+#else
+       .word   handler_irq     ! 0x0c
+       !SAVE_ALL
+1:     set     (CONFIG_SYS_RELOC_MONITOR_BASE-CONFIG_SYS_TEXT_BASE), %l6
+#endif
+       add     %l4, %l6, %l4           ! relocated trap_setup
+       jmpl    %l4, %l6
+        mov    %l5, %o7                ! restore orignal %o7
 
        or      %l0, PSR_PIL, %g2
        wr      %g2, 0x0, %psr
@@ -394,10 +489,15 @@ _irq_entry:
        wr      %g2, PSR_ET, %psr
        WRITE_PAUSE
        mov     %l7, %o0                ! irq level
-       set     handler_irq, %o1
+#ifdef CONFIG_SYS_GENERIC_BOARD
+       call    handler_irq             ! relative jump to handle_irq
+#else
+       sub     %l6, 0x18, %o2          ! calculate _irq_entry address
+       ld      [%o2 + 0x0c], %o1       ! handler_irq
        set     (CONFIG_SYS_RELOC_MONITOR_BASE-CONFIG_SYS_TEXT_BASE), %o2
        add     %o1, %o2, %o1
        call    %o1
+#endif
        add     %sp, SF_REGS_SZ, %o1    ! pt_regs ptr
        or      %l0, PSR_PIL, %g2       ! restore PIL after handler_irq
        wr      %g2, PSR_ET, %psr       ! keep ET up
@@ -405,79 +505,9 @@ _irq_entry:
 
        RESTORE_ALL
 
-!Window overflow trap handler.
-       .global _window_overflow
-
-_window_overflow:
-
-       mov     %wim, %l3               ! Calculate next WIM
-       mov     %g1, %l7
-       srl     %l3, 1, %g1
-       sll     %l3, (CONFIG_SYS_SPARC_NWINDOWS-1) , %l4
-       or      %l4, %g1, %g1
+!-------------------------------------------------------------------------------
 
-       save                            ! Get into window to be saved.
-       mov     %g1, %wim
-       nop;
-       nop;
        nop
-       st      %l0, [%sp + 0];
-       st      %l1, [%sp + 4];
-       st      %l2, [%sp + 8];
-       st      %l3, [%sp + 12];
-       st      %l4, [%sp + 16];
-       st      %l5, [%sp + 20];
-       st      %l6, [%sp + 24];
-       st      %l7, [%sp + 28];
-       st      %i0, [%sp + 32];
-       st      %i1, [%sp + 36];
-       st      %i2, [%sp + 40];
-       st      %i3, [%sp + 44];
-       st      %i4, [%sp + 48];
-       st      %i5, [%sp + 52];
-       st      %i6, [%sp + 56];
-       st      %i7, [%sp + 60];
-       restore                         ! Go back to trap window.
-       mov     %l7, %g1
-       jmp     %l1                     ! Re-execute save.
-       rett    %l2
-
-/* Window underflow trap handler.  */
-
-       .global  _window_underflow
-
-_window_underflow:
-
-       mov  %wim, %l3                  ! Calculate next WIM
-       sll  %l3, 1, %l4
-       srl  %l3, (CONFIG_SYS_SPARC_NWINDOWS-1), %l5
-       or   %l5, %l4, %l5
-       mov  %l5, %wim
-       nop; nop; nop
-       restore                         ! Two restores to get into the
-       restore                         ! window to restore
-       ld      [%sp + 0], %l0;         ! Restore window from the stack
-       ld      [%sp + 4], %l1;
-       ld      [%sp + 8], %l2;
-       ld      [%sp + 12], %l3;
-       ld      [%sp + 16], %l4;
-       ld      [%sp + 20], %l5;
-       ld      [%sp + 24], %l6;
-       ld      [%sp + 28], %l7;
-       ld      [%sp + 32], %i0;
-       ld      [%sp + 36], %i1;
-       ld      [%sp + 40], %i2;
-       ld      [%sp + 44], %i3;
-       ld      [%sp + 48], %i4;
-       ld      [%sp + 52], %i5;
-       ld      [%sp + 56], %i6;
-       ld      [%sp + 60], %i7;
-       save                            ! Get back to the trap window.
-       save
-       jmp     %l1                     ! Re-execute restore.
-       rett    %l2
-
-       retl
 
 _nmi_trap:
        nop
@@ -597,6 +627,12 @@ ret_trap_entry:
  * It resets the system by jumping to _start
  */
 _reset_reloc:
-       set     start, %l0
+#if 1 /* DEBUG: When we run in GRMON, use the trap to exit normally. */
+       mov     1, %g1
+       ta      0       ! Cause program to exit normally in GRMON
+        nop
+#else
+       set     CONFIG_SYS_RELOC_MONITOR_BASE, %l0
        call    %l0
-       nop
+        nop
+#endif

--
1.9.3

________________________________
Disclaimer and confidentiality note ? refer to our website for further details: www.spaceteq.co.za <http://www.spaceteq.co.za/home/emaildisclaimer/>

#6 lore raw

RFC PATCH 6/9 sparc: Update all LEON3 boards to generic board-init

In reply to Francois Retief

Add the CONFIG_SYS_GENERIC_BOARD variable to all the LEON3 boards.

---

 include/configs/gr_cpci_ax2000.h | 2 ++
 include/configs/gr_ep2s60.h      | 2 ++
 include/configs/gr_xc3s_1500.h   | 2 ++
 include/configs/grsim.h          | 2 ++
 4 files changed, 8 insertions(+)
include/configs/gr_cpci_ax2000.h +2 -0
index 854807d..ca7f123 100644
@@ -14,6 +14,8 @@
 #ifndef __CONFIG_H__
 #define __CONFIG_H__
 
+#define CONFIG_SYS_GENERIC_BOARD 1
+
 /*
  * High Level Configuration Options
  * (easy to change)
include/configs/gr_ep2s60.h +2 -0
index ed2dd2a..e337def 100644
@@ -15,6 +15,8 @@
 #ifndef __CONFIG_H__
 #define __CONFIG_H__
 
+#define CONFIG_SYS_GENERIC_BOARD 1
+
 /*
  * High Level Configuration Options
  * (easy to change)
include/configs/gr_xc3s_1500.h +2 -0
index e3cbb6f..bcad964 100644
@@ -13,6 +13,8 @@
 #ifndef __CONFIG_H__
 #define __CONFIG_H__
 
+#define CONFIG_SYS_GENERIC_BOARD 1
+
 /*
  * High Level Configuration Options
  * (easy to change)
include/configs/grsim.h +2 -0
index 1e089a9..dc1f04c 100644
@@ -13,6 +13,8 @@
 #ifndef __CONFIG_H__
 #define __CONFIG_H__
 
+#define CONFIG_SYS_GENERIC_BOARD 1
+
 /*
  * High Level Configuration Options
  * (easy to change)

--
1.9.3

________________________________
Disclaimer and confidentiality note ? refer to our website for further details: www.spaceteq.co.za <http://www.spaceteq.co.za/home/emaildisclaimer/>

#7 lore raw

RFC PATCH 7/9 sparc: Make LEON serial drivers use readl/writel macros

In reply to Francois Retief

Update the LEON2/3 serial driver to make use of the readl and writel macros as well as the WATCHDOG_RESET() macro.

Also, added readl/writel and friends to the asm/io.h file.

---

 arch/sparc/cpu/leon2/serial.c | 121 +++++++++++++++++++-----------------------
 arch/sparc/cpu/leon3/serial.c |  93 +++++++++++++++++---------------
 arch/sparc/include/asm/io.h   |  43 ++++++++-------
 3 files changed, 130 insertions(+), 127 deletions(-)
arch/sparc/cpu/leon2/serial.c +55 -66
index 5cfbb9e..9fe4fdd 100644
@@ -7,66 +7,68 @@
  */
 
 #include <common.h>
+#include <asm/io.h>
 #include <asm/processor.h>
-#include <asm/leon.h>
 #include <serial.h>
-#include <linux/compiler.h>
+#include <watchdog.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static int leon2_serial_init(void)
+static inline LEON2_Uart_regs *leon2_get_uart_regs(void)
 {
        LEON2_regs *leon2 = (LEON2_regs *) LEON2_PREGS;
-       LEON2_Uart_regs *regs;
-       unsigned int tmp;
 
-       /* Init LEON2 UART
-        *
-        * Set scaler / baud rate
-        *
-        * Receiver & transmitter enable
-        */
 #if LEON2_CONSOLE_SELECT == LEON_CONSOLE_UART1
-       regs = (LEON2_Uart_regs *) & leon2->UART_Channel_1;
+       return (LEON2_Uart_regs *)&leon2->UART_Channel_1;
 #else
-       regs = (LEON2_Uart_regs *) & leon2->UART_Channel_2;
+       return (LEON2_Uart_regs *)&leon2->UART_Channel_2;
 #endif
+}
 
-       regs->UART_Scaler = CONFIG_SYS_LEON2_UART1_SCALER;
+static int leon2_serial_init(void)
+{
+       LEON2_Uart_regs *uart = leon2_get_uart_regs();
+       unsigned int tmp;
 
-       /* Let bit 11 be unchanged (debug bit for GRMON) */
-       tmp = READ_WORD(regs->UART_Control);
+       /* Init LEON2 UART */
+       if (!uart)
+               return -1;
 
-       regs->UART_Control = ((tmp & LEON2_UART_CTRL_DBG) |
-                             (LEON2_UART1_LOOPBACK_ENABLE << 7) |
-                             (LEON2_UART1_FLOWCTRL_ENABLE << 6) |
-                             (LEON2_UART1_PARITY_ENABLE << 5) |
-                             (LEON2_UART1_ODDPAR_ENABLE << 4) |
-                             LEON2_UART_CTRL_RE | LEON2_UART_CTRL_TE);
+       /* Set scaler / baud rate */
+       tmp = (((CONFIG_SYS_CLK_FREQ * 10)/(CONFIG_BAUDRATE * 8)) - 5) / 10;
+       writel(tmp, &uart->UART_Scaler);
+
+       /* Let bit 11 be unchanged (debug bit for GRMON) */
+       tmp = readl(&uart->UART_Control) & LEON2_UART_CTRL_DBG;
+       tmp |= (LEON2_UART1_LOOPBACK_ENABLE << 7);
+       tmp |= (LEON2_UART1_FLOWCTRL_ENABLE << 6);
+       tmp |= (LEON2_UART1_PARITY_ENABLE << 5);
+       tmp |= (LEON2_UART1_ODDPAR_ENABLE << 4);
+       /* Receiver & transmitter enable */
+       tmp |= (LEON2_UART_CTRL_RE | LEON2_UART_CTRL_TE);
+       writel(tmp, &uart->UART_Control);
 
        return 0;
 }
 
 static void leon2_serial_putc_raw(const char c)
 {
-       LEON2_regs *leon2 = (LEON2_regs *) LEON2_PREGS;
-       LEON2_Uart_regs *regs;
+       LEON2_Uart_regs *uart = leon2_get_uart_regs();
 
-#if LEON2_CONSOLE_SELECT == LEON_CONSOLE_UART1
-       regs = (LEON2_Uart_regs *) & leon2->UART_Channel_1;
-#else
-       regs = (LEON2_Uart_regs *) & leon2->UART_Channel_2;
-#endif
+       if (!uart)
+               return;
 
        /* Wait for last character to go. */
-       while (!(READ_WORD(regs->UART_Status) & LEON2_UART_STAT_THE)) ;
+       while (!(readl(&uart->UART_Status) & LEON2_UART_STAT_THE))
+               WATCHDOG_RESET();
 
        /* Send data */
-       regs->UART_Channel = c;
+       writel(c, &uart->UART_Channel);
 
 #ifdef LEON_DEBUG
        /* Wait for data to be sent */
-       while (!(READ_WORD(regs->UART_Status) & LEON2_UART_STAT_TSE)) ;
+       while (!(readl(&uart->UART_Status) & LEON2_UART_STAT_TSE))
+               WATCHDOG_RESET();
 #endif
 }
 
@@ -80,56 +82,43 @@ static void leon2_serial_putc(const char c)
 
 static int leon2_serial_getc(void)
 {
-       LEON2_regs *leon2 = (LEON2_regs *) LEON2_PREGS;
-       LEON2_Uart_regs *regs;
+       LEON2_Uart_regs *uart = leon2_get_uart_regs();
 
-#if LEON2_CONSOLE_SELECT == LEON_CONSOLE_UART1
-       regs = (LEON2_Uart_regs *) & leon2->UART_Channel_1;
-#else
-       regs = (LEON2_Uart_regs *) & leon2->UART_Channel_2;
-#endif
+       if (!uart)
+               return 0;
 
-       /* Wait for a character to arrive. */
-       while (!(READ_WORD(regs->UART_Status) & LEON2_UART_STAT_DR)) ;
+       /* Wait for a character to arrive */
+       while (!(readl(&uart->UART_Status) & LEON2_UART_STAT_DR))
+               WATCHDOG_RESET();
 
-       /* read data */
-       return READ_WORD(regs->UART_Channel);
+       /* Read character data */
+       return readl(&uart->UART_Channel);
 }
 
 static int leon2_serial_tstc(void)
 {
-       LEON2_regs *leon2 = (LEON2_regs *) LEON2_PREGS;
-       LEON2_Uart_regs *regs;
+       LEON2_Uart_regs *uart = leon2_get_uart_regs();
 
-#if LEON2_CONSOLE_SELECT == LEON_CONSOLE_UART1
-       regs = (LEON2_Uart_regs *) & leon2->UART_Channel_1;
-#else
-       regs = (LEON2_Uart_regs *) & leon2->UART_Channel_2;
-#endif
+       if (!uart)
+               return 0;
 
-       return (READ_WORD(regs->UART_Status) & LEON2_UART_STAT_DR);
+       return readl(&uart->UART_Status) & LEON2_UART_STAT_DR;
 }
 
-/* set baud rate for uart */
 static void leon2_serial_setbrg(void)
 {
-       /* update baud rate settings, read it from gd->baudrate */
+       LEON2_Uart_regs *uart = leon2_get_uart_regs();
        unsigned int scaler;
-       LEON2_regs *leon2 = (LEON2_regs *) LEON2_PREGS;
-       LEON2_Uart_regs *regs;
 
-#if LEON2_CONSOLE_SELECT == LEON_CONSOLE_UART1
-       regs = (LEON2_Uart_regs *) & leon2->UART_Channel_1;
-#else
-       regs = (LEON2_Uart_regs *) & leon2->UART_Channel_2;
-#endif
+       if (!uart)
+               return;
+
+       if (!gd->baudrate)
+               gd->baudrate = CONFIG_BAUDRATE;
+
+       scaler = (((CONFIG_SYS_CLK_FREQ * 10)/(gd->baudrate * 8)) - 5) / 10;
 
-       if (gd->baudrate > 0) {
-               scaler =
-                   (((CONFIG_SYS_CLK_FREQ * 10) / (gd->baudrate * 8)) -
-                    5) / 10;
-               regs->UART_Scaler = scaler;
-       }
+       writel(scaler, &uart->UART_Scaler);
 }
 
 static struct serial_device leon2_serial_drv = {
arch/sparc/cpu/leon3/serial.c +50 -43

145 lines not on this page · raw message

arch/sparc/include/asm/io.h +25 -18

62 lines not on this page · raw message

--
1.9.3

________________________________
Disclaimer and confidentiality note ? refer to our website for further details: www.spaceteq.co.za <http://www.spaceteq.co.za/home/emaildisclaimer/>

#8 lore raw

RFC PATCH 8/9 sparc: Add MDIO support to GRETH driver

In reply to Francois Retief

Added MDIO support to the Aeroflex Gaisler GRETH driver. The result is that we can now use the CONFIG_CMD_MII commands to access the PHY chip.

---

 drivers/net/greth.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 57 insertions(+)
drivers/net/greth.c +57 -0
index 7784684..5f5abd6 100644
@@ -18,6 +18,8 @@
 #include <asm/processor.h>
 #include <ambapp.h>
 #include <asm/leon.h>
+#include <miiphy.h>
+#include <errno.h>
 
 #include "greth.h"
 
@@ -52,6 +54,7 @@ typedef struct {
        greth_regs *regs;
        int irq;
        struct eth_device *dev;
+       struct mii_dev *bus;
 
        /* Hardware info */
        unsigned char phyaddr;
@@ -124,6 +127,57 @@ static void write_mii(int phyaddr, int regaddr, int data, volatile greth_regs *
 
 }
 
+#ifdef CONFIG_MII
+
+static int greth_mdio_read(struct mii_dev *bus, int port_addr, int dev_addr, int regnum)
+{
+       greth_regs *regs = (greth_regs *)bus->priv;
+
+       debug("GRETH: mdio_read (port_addr=%d, dev_addr=%d, reg=%d)\n", port_addr, dev_addr, regnum);
+
+       return read_mii(port_addr, regnum, regs);
+}
+
+static int greth_mdio_write(struct mii_dev *bus, int port_addr, int dev_addr, int regnum, u16 value)
+{
+       greth_regs *regs = (greth_regs *)bus->priv;
+
+       debug("GRETH: mdio_write (port_addr=%d, dev_addr=%d, reg=%d, value=%d)\n", port_addr, dev_addr, regnum, value);
+
+       write_mii(port_addr, regnum, value, regs);
+       return 0;
+}
+
+static int greth_mdio_reset(struct mii_dev *bus)
+{
+       puts("GRETH: Reset PHY via MDIO reset\n");
+       return 0;
+}
+
+int greth_mdio_register(greth_priv *greth, bd_t *bis)
+{
+       struct mii_dev *bus = mdio_alloc();
+
+       if (!bus) {
+               printf("GRETH: Failed to allocate MDIO bus\n");
+               return -ENOMEM;
+       }
+
+       bus->read = greth_mdio_read;
+       bus->write = greth_mdio_write;
+       bus->reset = greth_mdio_reset;
+       sprintf(bus->name, "GRETH%d", 0);
+
+       bus->priv = (void *)greth->regs;
+       greth->bus = bus;
+
+       return mdio_register(bus);
+}
+
+#else
+static inline int greth_mdio_register(greth_priv *greth, bd_t *bis) { return 0; }
+#endif /* CONFIG_CMD_MII */
+
 /* init/start hardware and allocate descriptor buffers for rx side
  *
  */
@@ -633,6 +687,9 @@ int greth_initialize(bd_t * bis)
                sprintf(dev->name, "GRETH_10/100");
        }
 
+       /* Register our device with the MDIO subsystem */
+       greth_mdio_register(greth, bis);
+
        /* initiate PHY, select speed/duplex depending on connected PHY */
        if (greth_init_phy(greth, bis)) {
                /* Failed to init PHY (timedout) */

--
1.9.3

________________________________
Disclaimer and confidentiality note ? refer to our website for further details: www.spaceteq.co.za <http://www.spaceteq.co.za/home/emaildisclaimer/>

#9 lore raw

RFC PATCH 9/9 sparc: Add support for gr712rc-board

In reply to Francois Retief

Add support of the Aeroflex Gaisler GR712RC-BOARD Development Kit.

---

 arch/sparc/Kconfig                          |   4 +
 board/gaisler/gr712rc_board/Kconfig         |  19 ++
 board/gaisler/gr712rc_board/MAINTAINERS     |   6 +
 board/gaisler/gr712rc_board/Makefile        |   8 +
 board/gaisler/gr712rc_board/README          |  24 ++
 board/gaisler/gr712rc_board/config.mk       |  15 ++
 board/gaisler/gr712rc_board/gr712rc_board.c | 110 +++++++++
 common/cmd_bdinfo.c                         |   4 +
 configs/gr712rc_board_defconfig             |   2 +
 include/configs/gr712rc_board.h             | 366 ++++++++++++++++++++++++++++
 10 files changed, 558 insertions(+)
 create mode 100644 board/gaisler/gr712rc_board/Kconfig
 create mode 100644 board/gaisler/gr712rc_board/MAINTAINERS
 create mode 100644 board/gaisler/gr712rc_board/Makefile
 create mode 100644 board/gaisler/gr712rc_board/README
 create mode 100644 board/gaisler/gr712rc_board/config.mk
 create mode 100644 board/gaisler/gr712rc_board/gr712rc_board.c
 create mode 100644 configs/gr712rc_board_defconfig
 create mode 100644 include/configs/gr712rc_board.h
arch/sparc/Kconfig +4 -0
index 733334f..21bef85 100644
@@ -22,6 +22,9 @@ config TARGET_GR_XC3S_1500
 config TARGET_GRSIM
        bool "Support grsim"
 
+config TARGET_GR712RC_BOARD
+       bool "Support gr712rc_board"
+
 endchoice
 
 source "board/gaisler/gr_cpci_ax2000/Kconfig"
@@ -29,5 +32,6 @@ source "board/gaisler/gr_ep2s60/Kconfig"
 source "board/gaisler/gr_xc3s_1500/Kconfig"
 source "board/gaisler/grsim/Kconfig"
 source "board/gaisler/grsim_leon2/Kconfig"
+source "board/gaisler/gr712rc_board/Kconfig"
 
 endmenu
board/gaisler/gr712rc_board/Kconfig new file +19 -0
new file mode 100644
index 0000000..e0af97c
@@ -0,0 +1,19 @@
+if TARGET_GR712RC_BOARD
+
+config SYS_CPU
+       string
+       default "leon3"
+
+config SYS_BOARD
+       string
+       default "gr712rc_board"
+
+config SYS_VENDOR
+       string
+       default "gaisler"
+
+config SYS_CONFIG_NAME
+       string
+       default "gr712rc_board"
+
+endif
board/gaisler/gr712rc_board/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000..329fcf9
@@ -0,0 +1,6 @@
+GR712RC BOARD
+#M:    -
+S:     New
+F:     board/gaisler/gr712rc/
+F:     include/configs/gr712rc.h
+F:     configs/gr712rc_defconfig
board/gaisler/gr712rc_board/Makefile new file +8 -0
new file mode 100644
index 0000000..11861ef
@@ -0,0 +1,8 @@
+#
+# (C) Copyright 2014, Denel Spaceteq
+# Francois Retief <[email protected]>
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+obj-y  := gr712rc_board.o
board/gaisler/gr712rc_board/README new file +24 -0
new file mode 100644
index 0000000..9deb239
@@ -0,0 +1,24 @@
+
+
+Jumpers for SDRAM:
+  JP12 = C     SDCSN0
+  JP13 = C     SDCSN1
+  JP24 = C     SDDQM0
+  JP25 = C     SDDQM1
+  JP48 = C     SDCASN
+  JP49 = C     SDRASN
+  JP52 = C     SDWEN
+  JP53 = C     SDDQM2
+  JP54 = C     SDDQM3
+
+Jumpers for Ethernet (RMII):
+  JP28 = F     RMTXD0
+  JP29 = F     RMTXD1
+  JP30 = F     RMRXD0
+  JP31 = F     RMRXD1
+  JP32 = F     RMTXEN
+  JP34 = F     RMCRSDV
+  JP35 = F     RMMDINT
+  JP36 = F     RMMDIO
+  JP37 = F     RMMDC
+  JP38 = F     RMRFCLK
board/gaisler/gr712rc_board/config.mk new file +15 -0
new file mode 100644
index 0000000..8594a74
@@ -0,0 +1,15 @@
+#
+# (C) Copyright 2014, Denel Spaceteq
+# Francois Retief <[email protected]>
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+# U-BOOT IN FLASH
+#CONFIG_SYS_TEXT_BASE = 0x00000000
+
+# U-BOOT IN SRAM
+#CONFIG_SYS_TEXT_BASE = 0x40000000
+
+# U-BOOT IN SDRAM
+CONFIG_SYS_TEXT_BASE = 0x60000000
board/gaisler/gr712rc_board/gr712rc_board.c new file +110 -0

110 lines not on this page · raw message

common/cmd_bdinfo.c +4 -0
index 3d37a86..6af5afe 100644
@@ -216,10 +216,14 @@ int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
        print_num("flashstart             ", bd->bi_flashstart);
        print_num("CONFIG_SYS_MONITOR_BASE       ", CONFIG_SYS_MONITOR_BASE);
        print_num("CONFIG_ENV_ADDR           ", CONFIG_ENV_ADDR);
+#ifdef CONFIG_SYS_RELOC_MONITOR_BASE
        printf("CONFIG_SYS_RELOC_MONITOR_BASE = 0x%x (%d)\n", CONFIG_SYS_RELOC_MONITOR_BASE,
               CONFIG_SYS_MONITOR_LEN);
+#endif
+#ifdef CONFIG_SYS_MALLOC_BASE
        printf("CONFIG_SYS_MALLOC_BASE        = 0x%x (%d)\n", CONFIG_SYS_MALLOC_BASE,
               CONFIG_SYS_MALLOC_LEN);
+#endif
        printf("CONFIG_SYS_INIT_SP_OFFSET     = 0x%x (%d)\n", CONFIG_SYS_INIT_SP_OFFSET,
               CONFIG_SYS_STACK_SIZE);
        printf("CONFIG_SYS_PROM_OFFSET        = 0x%x (%d)\n", CONFIG_SYS_PROM_OFFSET,
configs/gr712rc_board_defconfig new file +2 -0
new file mode 100644
index 0000000..76e259e
@@ -0,0 +1,2 @@
+CONFIG_SPARC=y
+CONFIG_TARGET_GR712RC_BOARD=y
include/configs/gr712rc_board.h new file +366 -0

366 lines not on this page · raw message

--
1.9.3

________________________________
Disclaimer and confidentiality note ? refer to our website for further details: www.spaceteq.co.za <http://www.spaceteq.co.za/home/emaildisclaimer/>

#10 lore raw

RFC PATCH 9/9 sparc: Add support for gr712rc-board

Hi Francois,

Quoted 5 lines · On Wed, 29 Oct 2014 10:53:07 +0200 Francois Retief <[email protected]>…

Add support of the Aeroflex Gaisler GR712RC-BOARD Development Kit.

---

Thanks for your great job!

I am sorry for bothering you work, but please let me do some cleanups before adding a new board because you are following the old style coding.
http://patchwork.ozlabs.org/patch/404889/
http://patchwork.ozlabs.org/patch/404887/
http://patchwork.ozlabs.org/patch/404886/
http://patchwork.ozlabs.org/patch/404888/
http://patchwork.ozlabs.org/patch/404890/

arch/sparc/Kconfig config TARGET_GR_XC3S_1500 · line 28

Quoted 13 lines
arch/sparc/Kconfig +3 -0
index 733334f..21bef85 100644
@@ -22,6 +22,9 @@ config TARGET_GR_XC3S_1500
 config TARGET_GRSIM
        bool "Support grsim"
 
+config TARGET_GR712RC_BOARD
+       bool "Support gr712rc_board"
+
 endchoice

Perhaps can we use better name?
The current prompts were automatically taken by a tool and I have to admint they are not very good.

Like this?
http://patchwork.ozlabs.org/patch/404889/

Quoted 23 lines
arch/sparc/Kconfig +1 -0
 source "board/gaisler/gr_cpci_ax2000/Kconfig"
@@ -29,5 +32,6 @@ source "board/gaisler/gr_ep2s60/Kconfig"
 source "board/gaisler/gr_xc3s_1500/Kconfig"
 source "board/gaisler/grsim/Kconfig"
 source "board/gaisler/grsim_leon2/Kconfig"
+source "board/gaisler/gr712rc_board/Kconfig"
 
 endmenu
board/gaisler/gr712rc_board/Kconfig new file +9 -0
new file mode 100644
index 0000000..e0af97c
@@ -0,0 +1,19 @@
+if TARGET_GR712RC_BOARD
+
+config SYS_CPU
+       string
+       default "leon3"
+
+config SYS_BOARD
+       string
+       default "gr712rc_board"

board/gaisler/gr712rc_board/Kconfig line 19

Quoted 10 lines
board/gaisler/gr712rc_board/Kconfig new file +10 -0
+
+config SYS_VENDOR
+       string
+       default "gaisler"
+
+config SYS_CONFIG_NAME
+       string
+       default "gr712rc_board"
+
+endif

I think we can save more lines.
Please check this:
http://patchwork.ozlabs.org/patch/404888/

board/gaisler/gr712rc_board/MAINTAINERS line 6

Quoted 12 lines
board/gaisler/gr712rc_board/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000..329fcf9
@@ -0,0 +1,6 @@
+GR712RC BOARD
+#M:    -
+S:     New
+F:     board/gaisler/gr712rc/
+F:     include/configs/gr712rc.h
+F:     configs/gr712rc_defconfig

Please use either "Maintained" or "Orphan" for the status field. In this case "Maintained", of course.

Quoted 11 lines
board/gaisler/gr712rc_board/config.mk new file +5 -0
new file mode 100644
index 0000000..8594a74
@@ -0,0 +1,15 @@
+#
+# (C) Copyright 2014, Denel Spaceteq
+# Francois Retief <[email protected]>
+#
+# SPDX-License-Identifier:     GPL-2.0+

board/gaisler/gr712rc_board/config.mk line 15

Quoted 10 lines
board/gaisler/gr712rc_board/config.mk new file +10 -0
+#
+
+# U-BOOT IN FLASH
+#CONFIG_SYS_TEXT_BASE = 0x00000000
+
+# U-BOOT IN SRAM
+#CONFIG_SYS_TEXT_BASE = 0x40000000
+
+# U-BOOT IN SDRAM
+CONFIG_SYS_TEXT_BASE = 0x60000000

Please do not define CONFIG_SYS_TEXT_BASE in config.mk; this is very old style. Add it in the defconfig, like this:
http://patchwork.ozlabs.org/patch/404890/

Best Regards
Masahiro Yamada