你好,游客 登录 注册 搜索
背景:
阅读新闻

ARMBoot-1.1.0 在 mini2440 开发板上的移植

[日期:2011-05-26] 来源:Linux社区  作者:jocks [字体:大 中 小]
参见前面在源代码中搜索到的和CONFIG_S3C2410,和CONFIG_SMDK2410的引用,
需要将 cpu/arm920t/interrupts.c ,cpu/arm920t/serial.c 中关于 对头文件 s3c2410.h 的包含指令改为对 s3c2440.h的包含指令,具体如下:

cpu/arm920t/interrupts.c
     1    /*
     2     * (C) Copyright 2002
     3     * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
     4     * Marius Groeger <mgroeger@sysgo.de>
     5     *
     6     * (C) Copyright 2002
     7     * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
     8     * Alex Zuepke <azu@sysgo.de>
     9     *
    10     * (C) Copyright 2002
    11     * Gary Jennejohn, DENX Software Engineering, <gj@denx.de>
    12     *
    13     * See file CREDITS for list of people who contributed to this
    14     * project.
    15     *
    16     * This program is free software; you can redistribute it and/or
    17     * modify it under the terms of the GNU General Public License as
    18     * published by the Free Software Foundation; either version 2 of
    19     * the License, or (at your option) any later version.
    20     *
    21     * This program is distributed in the hope that it will be useful,
    22     * but WITHOUT ANY WARRANTY; without even the implied warranty of
    23     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    24     * GNU General Public License for more details.
    25     *
    26     * You should have received a copy of the GNU General Public License
    27     * along with this program; if not, write to the Free Software
    28     * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
    29     * MA 02111-1307 USA
    30     */
    31   
    32    #include "armboot.h"
    33    #include "arm920t.h"
    34    #if defined(CONFIG_S3C2400)
    35    #include "s3c2400.h"
    36    #elif defined(CONFIG_S3C2410)
    37    #include "s3c2410.h"
    38    #elif defined(CONFIG_S3C2440)    /* snallie, Tue Mar 15 16:06:21 CST 2011 */
    39    #include "s3c2440.h"        /* snallie, attention that the include object maybe s3c2440.h ! */
        /*
         * 38~39为新加入的指令,在配置文件include/configs/config_mini2440.h 中将定义宏CONFIG_S3C2440 ,这样将会使s3c2440.h被包含进来
         * 因为MINI2440板上的处理器为S3C2440,所以s3c2440.h是应该被包含进来的头文件,本文件只修改这一处。
         */   
    40    #endif
    41   
    42    #include "ptregs.h"
    43   
    44    extern void reset_cpu(ulong addr);
    45   
    46    /* for 10 ms clock period @ 50 MHz with 4 bit divider = 1/2 (default) */
    47    /* and prescaler = 16 */
    48    #define TIMER_LOAD_VAL 15625
    49   
    50    /* macro to read the 16 bit timer */
    51    #define READ_TIMER (rTCNTO4 & 0xffff)
    52   
    53    #ifdef CONFIG_USE_IRQ
    54    /* enable IRQ interrupts */
    55    void enable_interrupts (void)
    56    {
    57        unsigned long temp;
    58        __asm__ __volatile__("mrs %0, cpsr\n"
    59                 "bic %0, %0, #0x80\n"
    60                 "msr cpsr_c, %0"
    61                 : "=r" (temp)
    62                 :
    63                 : "memory");
    64    }
    65   
    66   
    67    /*
    68     * disable IRQ/FIQ interrupts
    69     * returns true if interrupts had been enabled before we disabled them
    70     */
    71    int disable_interrupts (void)
    72    {
    73        unsigned long old,temp;
    74        __asm__ __volatile__("mrs %0, cpsr\n"
    75                 "orr %1, %0, #0xc0\n"
    76                 "msr cpsr_c, %1"
    77                 : "=r" (old), "=r" (temp)
    78                 :
    79                 : "memory");
    80        return (old & 0x80) == 0;
    81    }
    82    #else
    83    void enable_interrupts (void)
    84    {
    85        return;
    86    }
    87    int disable_interrupts (void)
    88    {
    89        return 0;
    90    }
    91    #endif
    92   
    93   
    94   
    95    void bad_mode(void)
    96    {
    97        panic("Resetting CPU ...\n");
    98        reset_cpu(0);
    99    }
   100   
   101    void show_regs(struct pt_regs * regs)
   102    {
   103        unsigned long flags;
   104    const char *processor_modes[]=
   105    { "USER_26", "FIQ_26" , "IRQ_26" , "SVC_26" , "UK4_26" , "UK5_26" , "UK6_26" , "UK7_26" ,
   106      "UK8_26" , "UK9_26" , "UK10_26", "UK11_26", "UK12_26", "UK13_26", "UK14_26", "UK15_26",
   107      "USER_32", "FIQ_32" , "IRQ_32" , "SVC_32" , "UK4_32" , "UK5_32" , "UK6_32" , "ABT_32" ,
   108      "UK8_32" , "UK9_32" , "UK10_32", "UND_32" , "UK12_32", "UK13_32", "UK14_32", "SYS_32"
   109    };
   110       
   111        flags = condition_codes(regs);
   112       
   113        printf("pc : [<%08lx>]    lr : [<%08lx>]\n"
   114           "sp : %08lx  ip : %08lx  fp : %08lx\n",
   115           instruction_pointer(regs),
   116           regs->ARM_lr, regs->ARM_sp,
   117           regs->ARM_ip, regs->ARM_fp);
   118        printf("r10: %08lx  r9 : %08lx  r8 : %08lx\n",
   119           regs->ARM_r10, regs->ARM_r9,
   120           regs->ARM_r8);
   121        printf("r7 : %08lx  r6 : %08lx  r5 : %08lx  r4 : %08lx\n",
   122           regs->ARM_r7, regs->ARM_r6,
   123           regs->ARM_r5, regs->ARM_r4);
   124        printf("r3 : %08lx  r2 : %08lx  r1 : %08lx  r0 : %08lx\n",
   125           regs->ARM_r3, regs->ARM_r2,
   126           regs->ARM_r1, regs->ARM_r0);
   127        printf("Flags: %c%c%c%c",
   128           flags & CC_N_BIT ? 'N' : 'n',
   129           flags & CC_Z_BIT ? 'Z' : 'z',
   130           flags & CC_C_BIT ? 'C' : 'c',
   131           flags & CC_V_BIT ? 'V' : 'v');
   132        printf("  IRQs %s  FIQs %s  Mode %s%s\n",
   133           interrupts_enabled(regs) ? "on" : "off",
   134           fast_interrupts_enabled(regs) ? "on" : "off",
   135           processor_modes[processor_mode(regs)],
   136           thumb_mode(regs) ? " (T)" : "");
   137    }
   138   
   139    void do_undefined_instruction(struct pt_regs *pt_regs)
   140    {
   141        printf("undefined instruction\n");
   142        show_regs(pt_regs);
   143        bad_mode();
   144    }
   145   
   146    void do_software_interrupt(struct pt_regs *pt_regs)
   147    {
   148        printf("software interrupt\n");
   149        show_regs(pt_regs);
   150        bad_mode();
   151    }
   152   
   153    void do_prefetch_abort(struct pt_regs *pt_regs)
   154    {
   155        printf("prefetch abort\n");
   156        show_regs(pt_regs);
   157        bad_mode();
   158    }
   159   
   160    void do_data_abort(struct pt_regs *pt_regs)
   161    {
   162        printf("data abort\n");
   163        show_regs(pt_regs);
   164        bad_mode();
   165    }
   166   
   167    void do_not_used(struct pt_regs *pt_regs)
   168    {
   169        printf("not used\n");
   170        show_regs(pt_regs);
   171        bad_mode();
   172    }
   173   
   174    void do_fiq(struct pt_regs *pt_regs)
   175    {
   176        printf("fast interrupt request\n");
   177        show_regs(pt_regs);
   178        bad_mode();
   179    }
   180   
   181    void do_irq(struct pt_regs *pt_regs)
   182    {
   183        printf("interrupt request\n");
   184        show_regs(pt_regs);
   185        bad_mode();
   186    }
   187   
   188    static ulong timestamp;
   189    static ulong lastdec;
   190   
   191    extern void interrupt_init (bd_t *bd)
   192    {
   193        /* use PWM Timer 4 because it has no output */
   194        /* prescaler for Timer 4 is 16 */
   195        rTCFG0 = 0x0f00;
   196        /* load value for 10 ms timeout, assumes PCLK is 30 MHz !! */
   197        lastdec = rTCNTB4 = TIMER_LOAD_VAL;
   198        /* auto load, manual update of Timer 4 */
   199        rTCON = 0x600000;
   200        /* auto load, start Timer 4 */
   201        rTCON = 0x500000;
   202        timestamp = 0;
   203    }
   204   
   205    /*
   206     * timer without interrupts
   207     */
   208   
   209    void reset_timer(void)
   210    {
   211        reset_timer_masked();
   212    }
   213   
   214    ulong get_timer (ulong base)
   215    {
   216        return get_timer_masked() - base;
   217    }
   218   
   219    void set_timer (ulong t)
   220    {
   221        timestamp = t;
   222    }
   223   
   224    void udelay(unsigned long usec)
   225    {
   226        ulong tmo;
   227   
   228        tmo = usec / 1000;
   229        tmo *= CFG_HZ;
   230        tmo /= 1000;
   231   
   232        tmo += get_timer(0);
   233   
   234        while(get_timer_masked() < tmo)
   235          /*NOP*/;
   236    }
   237   
   238    void reset_timer_masked(void)
   239    {
   240        /* reset time */
   241        lastdec = READ_TIMER;
   242        timestamp = 0;
   243    }
   244   
   245    ulong get_timer_masked(void)
   246    {
   247        ulong now = READ_TIMER;
   248   
   249        if (lastdec >= now)
   250        {
   251            /* normal mode */
   252            timestamp += lastdec - now;
   253        } else {
   254            /* we have an overflow ... */
   255            timestamp += lastdec + TIMER_LOAD_VAL - now;
   256        }
   257        lastdec = now;
   258   
   259        return timestamp;
   260    }
   261   
   262    void udelay_masked(unsigned long usec)
   263    {
   264        ulong tmo;
   265   
   266        tmo = usec / 1000;
   267        tmo *= CFG_HZ;
   268        tmo /= 1000;
   269   
   270        reset_timer_masked();
   271   
   272        while(get_timer_masked() < tmo)
   273          /*NOP*/;
   274    }
   275   

//////////////
 cpu/arm920t/serial.c的修改:

     1    /*
     2     * (C) Copyright 2002
     3     * Gary Jennejohn, DENX Software Engineering, <gj@denx.de>
     4     *
     5     * This program is free software; you can redistribute it and/or modify
     6     * it under the terms of the GNU General Public License as published by
     7     * the Free Software Foundation; either version 2 of the License, or
     8     * (at your option) any later version.
     9     *
    10     * This program is distributed in the hope that it will be useful,
    11     * but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    13     * GNU General Public License for more details.
    14     *
    15     * You should have received a copy of the GNU General Public License
    16     * along with this program; if not, write to the Free Software
    17     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    18     *
    19     */
    20   
    21    #include "armboot.h"
    22    #include "arm920t.h"
    23    #if defined(CONFIG_S3C2400)
    24    #include "s3c2400.h"
    25    #elif defined(CONFIG_S3C2410)
    26    #include "s3c2410.h"
    27    #elif defined(CONFIG_S3C2440)    /* snallie, Tue Mar 15 16:06:21 CST 2011 */
    28    #include "s3c2440.h"        /* snallie, attention that the include object maybe s3c2440.h ! */
        /*
         * 27~28为新加入的指令,在配置文件include/configs/config_mini2440.h 中将定义宏CONFIG_S3C2440 ,这样将会使s3c2440.h被包含进来
         * 因为MINI2440板上的处理器为S3C2440,所以s3c2440.h是应该被包含进来的头文件,本文件只修改这一处。
         */       
    29    #endif
    30   
    31    unsigned int br[] = {1562, 780, 390, 194, 32, 15};
    32    void serial_setbrg(bd_t *bd, int baudrate)
    33    {
    34        int i;
    35        unsigned int reg = 0;
    36   
    37    #if defined(CONFIG_SMDK2400)
    38        /* this assumes a PCLK of 50 MHz */
    39        /* value is calculated so : (int)(PCLK/16./baudrate) -1 */
    40        if (baudrate == 1200)        reg = 2603;
    41        else if (baudrate == 9600)   reg = 325;
    42        else if (baudrate == 19200)  reg = 162;
    43        else if (baudrate == 38400)  reg = 80;
    44        else if (baudrate == 57600)  reg = 53;
    45        else if (baudrate == 115200) reg = 26;
    46        else hang();
    47    #elif defined(CONFIG_SMDK2410) || defined(CONFIG_MINI2440)  /* snallie */
        /*
         * 47行追加 || defined(CONFIG_MINI2440),在配置文件include/configs/config_mini2440.h 中将定义宏CONFIG_MINI2440 ,这样将会使得
         * 下面的串口的波特率被设定为正确的值。
         */       
    48        /* this assumes a PCLK of 50.7 MHz */
    49        /* value is calculated so : (int)(PCLK/16./baudrate) -1 */
    50        if (baudrate == 1200)        reg = 2639;
    51        else if (baudrate == 9600)   reg = 329;
    52        else if (baudrate == 19200)  reg = 164;
    53        else if (baudrate == 38400)  reg = 82;
    54        else if (baudrate == 57600)  reg = 54;
    55        else if (baudrate == 115200) reg = 27;
    56        else hang();
    57    #else
    58    # error Bord config missing
    59    #endif
    60   
    61    #ifdef CONFIG_SERIAL1
    62        /* FIFO enable, Tx/Rx FIFO clear */
    63        rUFCON0 = 0x06;
    64        rUMCON0 = 0x0;
    65        /* Normal,No parity,1 stop,8 bit */
    66        rULCON0 = 0x3;
    67        /*
    68         * tx=level,rx=edge,disable timeout int.,enable rx error int.,
    69         * normal,interrupt or polling
    70         */
    71        rUCON0 = 0x245;
    72        rUBRDIV0 = reg;
    73   
    74        for(i=0;i<100;i++);
    75    #elif CONFIG_SERIAL2
    76        /* FIFO enable, Tx/Rx FIFO clear */
    77        rUFCON1 = 0x06;
    78        rUMCON1 = 0x0;
    79        /* Normal,No parity,1 stop,8 bit */
    80        rULCON1 = 0x3;
    81        /*
    82         * tx=level,rx=edge,disable timeout int.,enable rx error int.,
    83         * normal,interrupt or polling
    84         */
    85        rUCON1 = 0x245;
    86        rUBRDIV1 = reg;
    87   
    88        for(i=0;i<100;i++);
    89    #else
    90    #error "Bad: you didn't configure serial ..."
    91    #endif
    92    }
    93   
    94    /*
    95     * Initialise the serial port with the given baudrate. The settings
    96     * are always 8 data bits, no parity, 1 stop bit, no start bits.
    97     *
    98     */
    99    void serial_init(bd_t *bd)
   100    {
   101        const char *baudrate;
   102   
   103        if ((baudrate = getenv(bd, "baudrate")) != 0)
   104          bd->bi_baudrate = simple_strtoul(baudrate, NULL, 10);
   105   
   106        serial_setbrg(bd, bd->bi_baudrate);
   107    }
   108   
   109    /*
   110     * Read a single byte from the serial port. Returns 1 on success, 0
   111     * otherwise. When the function is succesfull, the character read is
   112     * written into its argument c.
   113     */
   114    int serial_getc(void)
   115    {
   116    #ifdef CONFIG_SERIAL1
   117        while(!(rUTRSTAT0 & 0x1))
   118            ;
   119   
   120        return rURXH0 & 0xff;
   121    #elif CONFIG_SERIAL2
   122        while(!(rUTRSTAT1 & 0x1))
   123            ;
   124   
   125        return rURXH1 & 0xff;
   126    #endif
   127    }
   128   
   129   
   130    /*
   131     * Output a single byte to the serial port.
   132     */
   133    void serial_putc(const char c)
   134    {
   135    #ifdef CONFIG_SERIAL1
   136        /* wait for room in the tx FIFO on SERIAL1 */
   137        while(!(rUTRSTAT0 & 0x2))
   138            ;
   139   
   140        rUTXH0 = c;
   141    #elif CONFIG_SERIAL2
   142        /* wait for room in the tx FIFO on SERIAL2 */
   143        while(!(rUTRSTAT1 & 0x2))
   144            ;
   145   
   146        rUTXH1= c;
   147    #endif
   148   
   149        /* If \n, also do \r */
   150        if(c == '\n')
   151          serial_putc('\r');
   152    }       
   153   
   154    /*
   155     * Test whether a character is in the RX buffer
   156     */
   157    int serial_tstc(void)
   158    {
   159    #ifdef CONFIG_SERIAL1
   160        return rUTRSTAT0 & 0x1;
   161    #elif CONFIG_SERIAL2
   162        return rUTRSTAT1 & 0x1;
   163    #endif
   164    }
   165   

///////////////

linux
相关资讯       mini2440 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款