]> www.infradead.org Git - users/rw/armboot.git/commitdiff
Changes to allow setting of clock frequency (only on shannon, so far)
authorrobertkaiser <robertkaiser>
Thu, 13 Mar 2003 18:17:12 +0000 (18:17 +0000)
committerrobertkaiser <robertkaiser>
Thu, 13 Mar 2003 18:17:12 +0000 (18:17 +0000)
board/shannon/shannon.c
include/cmd_bsp.h
include/configs/config_shannon.h

index 54286ab85904b85fc11de6e5e81dd75b1c0963c6..5314bca3289a8c11a5fd4bd001f2484ce6083f49 100644 (file)
@@ -23,6 +23,8 @@
  */
 
 #include "armboot.h"
+#include "command.h"
+#include <SA-1100.h>
 
 /* ------------------------------------------------------------------------- */
 
  * Miscelaneous platform dependent initialisations
  */
 
+struct clocksetup
+{
+       int           clockspeed;       /* frequency in MHz */
+       unsigned long ppcr;                     /* value for core clock config */
+       unsigned long mdcas0;           /* CAS timing ... */
+       unsigned long mdcas1;
+       unsigned long mdcas2;
+       unsigned long mdcnfg;
+       unsigned long msc0;
+       unsigned long mecr;                     /* PCMCIA timing */
+       unsigned long lccr3;            /* pixel clock divider */
+};
+
+
+const static struct clocksetup speeds[] =
+{
+       {
+               103,
+               0x00000003,
+               0xcccccccf,
+               0xfffffffc,
+               0xffffffff,
+               0x0326991f,
+               0x42304230,
+               0x00c600c6,
+               0x00000008
+       },
+       {
+               190,
+               0x00000009,
+               0xc71c703f,
+               0xffc71c71,
+               0xffffffff,
+               0x01b4b21f,
+               0x44584458,
+               0x016b016b,
+               0x0000000f
+       },
+       {
+               206,
+               0x0000000a,
+               0xc71c703f,
+               0xffc71c71,
+               0xffffffff,
+               0x0194b21f,
+               0x84c084c0,
+               0x018c018c,
+               0x00000010
+       }
+};
+
 int board_init(bd_t *bd)
 {
     /* memory and cpu-speed are setup before relocation */
@@ -58,7 +111,7 @@ int board_init(bd_t *bd)
         *(unsigned long *)temp = 0x00060006;
 
     }
-    #endif /* CONFIG_INIT_CRITICAL */
+    #endif /* CONFIG_INFERNO */
 
     /* arch number for shannon */
     bd->bi_arch_number = 97;
@@ -97,3 +150,43 @@ int dram_init(bd_t *bd)
     #endif
     ;
 }
+
+#ifdef CONFIG_CMD_SETCLOCK
+int set_clock(int clockspeed)
+{
+       int i;
+
+       for(i = 0; i < sizeof(speeds) / sizeof(speeds[0]); i++)
+       {
+               if(speeds[i].clockspeed == clockspeed)
+               {
+                       PPCR     = speeds[i].ppcr;
+                       MSC0     = speeds[i].msc0;
+                       MDCAS0   = speeds[i].mdcas0;
+                       MDCAS1   = speeds[i].mdcas1;
+                       MDCAS2   = speeds[i].mdcas2;
+                       MDCNFG   = speeds[i].mdcnfg;
+                       MECR     = speeds[i].mecr;
+                       LCCR3    = speeds[i].lccr3;
+                       return(0);
+               }
+       }
+       printf("Available clockspeeds are:\n");
+       for(i = 0; i < sizeof(speeds) / sizeof(speeds[0]); i++)
+               printf("   %d\n", speeds[i].clockspeed);
+       return(-1);
+}
+
+
+int do_setclock (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
+{
+    if (argc != 2) {
+        printf ("Usage:\n%s\n", cmdtp->usage);
+        return 1;
+    }
+
+    return(set_clock(simple_strtoul(argv[1], NULL, 10)));
+}
+
+
+#endif                 
index 5821de3bc859f478d93ba630f37d44d9d6c08a8e..066f96d603a2fe1eb8aef455c3f7d75ad9954f04 100644 (file)
 
 #if (CONFIG_COMMANDS & CFG_CMD_BSP)
 
+#ifdef CONFIG_CMD_SETCLOCK
+
+extern int do_setclock (cmd_tbl_t *, bd_t *, int , int, char **);
+
+#define CMD_TBL_BSP    MK_CMD_TBL_ENTRY(                   \
+    "setclock", 5,  2,  2,  do_setclock,            \
+    "setclock- set processor clock\n",               \
+    "N\n"                                   \
+    "    - set processor clock to N MHz (N is _decimal_ !!!)\n"     \
+),
+
+#endif /* CFG_CMD_BSP */
+
 #else
 
 #define CMD_TBL_BSP
index 06d4873f6a4d15c61f2d16f06379c9c90d2509ed..1e40155c6257a69c52cd7634168559098ae3b853 100644 (file)
 #define __CONFIG_H
 
 /*
- * If we are developing, we might want to start armboot from ram
- * so we MUST NOT initialize critical regs like mem-timing ...
+ * If we want to rely on the Inferno Loader to bring us to life, 
+ * we must use a different flash ROM layout, and we must initialze
+ * a few more things..
  */
+/*#undef CONFIG_INFERNO*/                      /* we are not using the inferno bootldr */
+#define CONFIG_INFERNO         /* we are using the inferno bootldr */
 
 /*
- * we just run in non-critical mode now, because we use the Inferno-Loader to
- * bring us to live
+ * If we are developing, we might want to start armboot from ram
+ * so we MUST NOT initialize critical regs like mem-timing in this case
  */
-#define CONFIG_INFERNO                 /* we are using the inferno bootldr */
-#undef CONFIG_INIT_CRITICAL            /* undef for developing */
+
+/*#define CONFIG_INIT_CRITICAL*/       /* undef for developing */
+#undef CONFIG_INIT_CRITICAL    /* undef for developing */
 
 /*
  * High Level Configuration Options
  * There are two possible drivers for the shannon's LCD screen,
  * select one of these:
  */
-#define CONFIG_ANSI_CONSOLE     /* ansi terminal emulation */
-#undef  CONFIG_CFB_CONSOLE      /* framebuffer console with std input */
-
-#ifdef CONFIG_ANSI_CONSOLE
-/* this set of defines will enable the generic frame buffer driver */
-#define CONFIG_FRAMEBUFFER                     /* use framebuffer */
-#define CONFIG_FRAMEBUFFER_BPP 8       /* 8 bits per pixel */
-#define CONFIG_FRAMEBUFFER_CLUT                /* h/w has color lookup table */
-#endif
-
-#ifdef CONFIG_CFB_CONSOLE
-#define CONFIG_CONSOLE_CURSOR   /* display cursor */
-#define CONFIG_VIDEO_LOGO       /* display linux logo */
-#define CONFIG_VIDEO_SHANNON   /* enable Shannon video driver */
-#endif
+#undef CONFIG_ANSI_CONSOLE     /* ansi terminal emulation */
+//#define CONFIG_ANSI_CONSOLE     /* ansi terminal emulation */
+#define CONFIG_CFB_CONSOLE      /* framebuffer console with std input */
+//#undef CONFIG_CFB_CONSOLE      /* framebuffer console with std input */
 
 /*
  * Keyboard device
+ *
+ * If you have enabled one of the LCD screen drivers above, you will
+ * most likely want to enable this as well ...
  */
 #define CONFIG_KEYBOARD                        /* enable generic keyboard driver */
 #define CONFIG_KEYBOARD_IRDA   /* use IrDA keyboard */
 
 #define CONFIG_COMMANDS                (CONFIG_CMD_DFL | \
                                 CFG_CMD_PCMCIA | \
+                                CFG_CMD_BSP | \
                                 CFG_CMD_IDE)
 
 /* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
 #include <cmd_confdefs.h>
 
 #define CONFIG_BOOTDELAY       3
+#ifdef CONFIG_KEYBOARD
+#define CONFIG_BOOTARGS        "root=ramfs devfs=mount"
+#else
 #define CONFIG_BOOTARGS        "root=ramfs devfs=mount console=ttySA0,115200"
-#define CONFIG_NETMASK          255.255.0.0
+#endif
+#define CONFIG_NETMASK      255.255.0.0
 #define CONFIG_BOOTCOMMAND     "help"
 
 #if (CONFIG_COMMANDS & CFG_CMD_KGDB)
 #define        CFG_LOAD_ADDR           0xd0000000      /* default load address */
 
 #define        CFG_HZ                  3686400         /* incrementer freq: 3.6864 MHz */
-#define CFG_CPUSPEED           0x09            /* 190 MHz for Shannon */
+
+/*
+** CPU clock selection: The inferno firmware initializes the
+** shanonn to 103MHz, however, in our experience, many tuxscreens
+** can be safely overclocked to 190 MHz, some even to 206 MHz.
+*/
+#define CFG_CPUSPEED           0x03            /* 103 MHz for Shannon */
+//#define CFG_CPUSPEED         0x09            /* 190 MHz for Shannon */
+//#define CFG_CPUSPEED         0x0a            /* 206 MHz for Shannon */
 
                                                /* valid baudrates */
 #define CFG_BAUDRATE_TABLE     { 9600, 19200, 38400, 57600, 115200 }
@@ -205,8 +214,8 @@ struct bd_info_ext
 #define CFG_ENV_ADDR           (PHYS_FLASH_1 + 0x003E0000)     /* Addr of Environment Sector   */
 #define CFG_ENV_SIZE           0x4000  /* Total Size of Environment Sector     */
 #else
-#define CFG_ENV_ADDR           (PHYS_FLASH_1 + 0x1C000)        /* Addr of Environment Sector   */
-#define CFG_ENV_SIZE           0x4000  /* Total Size of Environment Sector     */
+#define CFG_ENV_ADDR           (PHYS_FLASH_1 + 0x20000)        /* Addr of Environment Sector   */
+#define CFG_ENV_SIZE           0x20000 /* Total Size of Environment Sector     */
 #endif
 
 /*-----------------------------------------------------------------------
@@ -258,6 +267,36 @@ struct bd_info_ext
 /* Offset for alternate registers      */
 #define CFG_ATA_ALT_OFFSET     (CFG_ATA_BASE_ADDR)
 
+/*-----------------------------------------------------------------------
+ * Further parameters for framebuffer driver
+ *-----------------------------------------------------------------------
+ */
+
+/* no need normally to change anything here */
+
+#ifdef CONFIG_ANSI_CONSOLE
+/* this set of defines will enable the generic frame buffer driver */
+#define CONFIG_FRAMEBUFFER                     /* use framebuffer */
+#define CONFIG_FRAMEBUFFER_BPP 8       /* 8 bits per pixel */
+#define CONFIG_FRAMEBUFFER_CLUT                /* h/w has color lookup table */
+#define CONFIG_ADJUST_LCD                      /* enable adjustment of LCD contrast/brightness*/
+#define CONFIG_PAGELENGTH      24              /* stop scrolling every 24 lines */
+#endif
+
+#ifdef CONFIG_CFB_CONSOLE
+#define CONFIG_CONSOLE_CURSOR   /* display cursor */
+#define CONFIG_VIDEO_LOGO       /* display linux logo */
+#define CONFIG_VIDEO_SHANNON   /* enable Shannon video driver */
+#define CONFIG_ADJUST_LCD              /* enable adjustment of LCD contrast/brightness*/
+#define CONFIG_PAGELENGTH      24      /* stop scrolling every 24 lines */
+#endif
+
+#ifdef CONFIG_KEYBOARD
+#define CFG_DEBOUNCE_TOUT      (CFG_HZ/10)     /* keyboard debounce timeout : 100 ms*/
+#endif
+
+#define CONFIG_CMD_SETCLOCK                    /* enable setting of CPU clock */
+
 /*-----------------------------------------------------------------------
  */