📄 aesop2440.c
字号:
/* * A EEEE SSSS OOO PPPP * A A E S O O P P * AAAAA EEEE SSSS O O PPPP * A A E S O O P * A A EEEE SSSS OOO P * * An Entertainment Solution On a Platform (AESOP) is a completely Open Source * based graphical user environment and suite of applications for PDAs and other * devices running Linux. It is included in various embedded Linux distributions * such as OpenZaurus - http://www.aesop-embedded.org * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Title : aesop2440.c * Author : * Created date : 2005. 06. 26. 22:56:57 KST * Description : * * $Revision: 1.3 $ * $Log: aesop2440.c,v $ * Revision 1.3 2005/07/07 15:46:59 linux4go * *** empty log message *** * * Revision 1.2 2005/07/05 14:16:41 jeenspa * usbdmass fixup, nand, mkyaffs * * Revision 1.1.1.1 2005/06/27 17:04:23 linuxpark * Initial import. * * * */ #ident "@(*) $Header: /cvsroot/aesop-embedded/u-boot-aesop/board/aesop2440/aesop2440.c,v 1.3 2005/07/07 15:46:59 linux4go Exp $"#include <common.h>#include <s3c2440.h>#include <command.h>#include <bmp_layout.h>#include <asm/sizes.h>#include "sd.h"/* ------------------------------------------------------------------------- */#define FCLK_SPEED 1#define USB_CLOCK 1#if CONFIG_SYS_CLK_FREQ == 16934400#if FCLK_SPEED == 0 /* Fout = 296.35MHz */#define M_MDIV 0x61#define M_PDIV 0x1#define M_SDIV 0x2#elif FCLK_SPEED == 1 /* Fout = 399.65MHz */#define M_MDIV 0x6E#define M_PDIV 0x3#define M_SDIV 0x1#endif#if USB_CLOCK == 0#define U_M_MDIV 0x3C#define U_M_PDIV 0x4#define U_M_SDIV 0x1#elif USB_CLOCK == 1#define U_M_MDIV 0x3C#define U_M_PDIV 0x4#define U_M_SDIV 0x2#endif#elif CONFIG_SYS_CLK_FREQ == 12000000#if FCLK_SPEED == 0 /* Fout = 304.00MHz */#define M_MDIV 0x44#define M_PDIV 0x1#define M_SDIV 0x1#elif FCLK_SPEED == 1 /* Fout = 405.00MHz */#define M_MDIV 0x7f#define M_PDIV 0x2#define M_SDIV 0x1#endif#if USB_CLOCK == 0#define U_M_MDIV 0x38#define U_M_PDIV 0x2#define U_M_SDIV 0x1#elif USB_CLOCK == 1#define U_M_MDIV 0x38#define U_M_PDIV 0x2#define U_M_SDIV 0x2#endif#else#error CONFIG_SYS_CLK_FREQ Not Defined#endif #define LCD_WIDTH 640#define LCD_HEIGHT 480#ifdef CONFIG_BZ2_LOGO#include <bzlib.h>#include "logo2.bmp.bz2.h"#elseint gunzip (void *, int, unsigned char *, unsigned long *); /* from cmd_bootm.c */#include "logo2.bmp.gz.h"#endifint usbdmass(char *); int do_bmpload_sub(unsigned char *, int, int, int);extern unsigned int SD_card_init(void);/* ------------------------------------------------------------------------- */void init_lcd(void){#ifdef CONFIG_AESOP_LCD S3C24X0_LCD * const lcd = S3C24X0_GetBase_LCD(); unsigned long fclk, hclk, pclk, vclk, hfreq, vfreq, i; unsigned long clkval, bppmode = 0xc; /* 24bpp .. when 16bpp, bppmode = 0xc */ unsigned long vbpd = 32, height = LCD_HEIGHT, vfpd= 9, vspw = 1; unsigned long hbpd = 47, width = LCD_WIDTH, hfpd = 16, hspw = 95; unsigned long invvclk = 0, invvline = 1, invvframe = 1, invvd = 0, invvden = 0; unsigned long bswp = 0, hwswp = 0, fbaddr = AESOP_FB_BASE; unsigned long val; char *fb; fclk = get_FCLK(); hclk = get_HCLK(); pclk = get_PCLK(); clkval = (((hclk / 10000000) / 2) - 1) & 0x3ff; vclk = hclk / (clkval * 2); hfreq = vclk / (width + hbpd + 1 + hfpd + 1 + hspw + 1); vfreq = hfreq / (height + vbpd + 1 + vfpd + 1 + vspw + 1); val = width * height * ((bppmode == 0xd) ? 4 : 2); fb = (char *)fbaddr; for (i = 0; i < val; i++) fb[i] = 0;/* { S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO(); gpio->GPCCON = 0xaaaaaaaa; // GPIO port C alt. function - LCD gpio->GPDCON = 0xaaaaaaaa; // GPIO port D alt. function - LCD gpio->GPBDAT |= 1 << 1; gpio->GPBCON = (gpio->GPBCON & ~(3 << (1 * 2))) | (1 << (1 * 2)); gpio->GPHDAT &= ~(1 << 6); gpio->GPHCON = (gpio->GPHCON & ~(3 << (6 * 2))) | (1 << (6 * 2)); }*/ lcd->LCDCON1 = (clkval << 8) | (3 << 5) | (bppmode << 1) | (0 << 0); lcd->LCDCON2 = (vbpd << 24) | ((height - 1 + 0) << 14) | (vfpd << 6) | (vspw << 0); lcd->LCDCON3 = (hbpd << 19) | ((width - 1) << 8) | (hfpd << 0); lcd->LCDCON4 = (hspw << 0); lcd->LCDCON5 = (0 << 12) | (1 << 11) | (invvclk << 10) | (invvline << 9) | (invvframe << 8) | (invvd << 7) | (invvden << 6) | (1 << 3) | (bswp << 1) | (hwswp << 0); lcd->LCDSADDR1 = (fbaddr >> 1); val = 4; if(bppmode == 0xc) val = 2; lcd->LCDSADDR2 = ((fbaddr & 0x3ffffe) + width * val * (height + 0)) >> 1; lcd->LCDSADDR3 = width * val / 2; lcd->LCDCON1 |= 1; // ENVID on { #define BMP_BUFFER 0x32000000 unsigned char *buff; unsigned int unc_len; int i; buff = (unsigned char *)BMP_BUFFER; unc_len = 0x400000;#ifdef CONFIG_BZ2_LOGO i = BZ2_bzBuffToBuffDecompress(buff, &unc_len, __logo2_bmp_bz2, __logo2_bmp_bz2_len, CFG_MALLOC_LEN < (4096 * 1024), 0); if (i != BZ_OK) { printf("Logo Image Error , BZ2 report error no %d\n", i); return; }#else i = gunzip(buff, unc_len, logo2_bmp_gz, &logo2_bmp_gz_len); if (i != 0) { printf("Logo Image Error , gunzip error\n"); return; }#endif do_bmpload_sub(buff, 0, 0, 0); }#endif /* CONFIG_AESOP_LCD */ return;}static inline void delay (unsigned long loops){ __asm__ volatile ("1:\n" "subs %0, %1, #1\n" "bne 1b":"=r" (loops):"0" (loops));}/* * Miscellaneous platform dependent initialisations */int board_init(void){ DECLARE_GLOBAL_DATA_PTR; S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER(); S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO(); /* Configure Clock Divider */ clk_power->CAMDIVN = 0; clk_power->CLKDIVN = 0x07; /* fclk:hclk:pclk = 1:3:6 */ /* to reduce PLL lock time, adjust the LOCKTIME register */ clk_power->LOCKTIME = 0xFFFFFF; /* configure MPLL */ clk_power->MPLLCON = ((M_MDIV << 12) + (M_PDIV << 4) + M_SDIV); /* some delay between MPLL and UPLL */ delay (4000); /* configure UPLL */ clk_power->UPLLCON = ((U_M_MDIV << 12) + (U_M_PDIV << 4) + U_M_SDIV); /* some delay between MPLL and UPLL */ delay (8000); /* set up the I/O ports */ /* gpio->GPADAT = 0x00200000; gpio->GPACON = 0x005e5e3f; gpio->GPBDAT = 0x00000022; gpio->GPBUP = 0x00000002; gpio->GPBCON = 0x00000514; gpio->GPCDAT = 0x000000e0; gpio->GPCUP = 0x0000ffff; gpio->GPCCON = 0xaaaa56a9; gpio->GPDDAT = 0x00000000; gpio->GPDUP = 0x0000ffff; gpio->GPDCON = 0xaaaaaaaa; gpio->GPEDAT = 0x00000000; gpio->GPEUP = 0x0000c7ff; gpio->GPECON = 0xa02aaaaa; gpio->GPFDAT = 0x00000000; gpio->GPFUP = 0x000000ff; gpio->GPFCON = 0x00000000; gpio->GPGDAT = 0x00001000; gpio->GPGUP = 0x0000fdfa; gpio->GPGCON = 0x01000108; gpio->GPHDAT = 0x00000001; gpio->GPHUP = 0x000001d7; gpio->GPHCON = 0x00005aa5;*/ /* set up the I/O ports */ gpio->GPACON = 0x007FFFFF; gpio->GPBCON = 0x00015556; //GPBCON=40; //gpio->GPBUP = 0x000007FF; gpio->GPCCON = 0xaa9556a9; //GPCCON=0; //gpio->GPCUP = 0x0000FFFF; gpio->GPDCON = 0xaa95aaa5; //pio->GPDDAT=0x10; //gpio->GPDUP = 0x0000FFFF; gpio->GPECON = 0xA56AABFF; //delay(100000); //GPECON=1<<22; //gpio->GPEUP = 0x0000FFFF; gpio->GPFCON = 0x000096AA; //GPFCON=0; //gpio->GPFUP = 0x000000FF; gpio->GPGCON = 0x00154766; //GPGCON=0; //gpio->GPGUP = 0x0000FFFF; gpio->GPHCON = 0x0014aaaa;// gpio->GPHUP = 0x000007FF; //gpio->GPJCON=0;#if 1 /* USB Device Part */ /*GPGCON is reset for USB Device */ gpio->GPGCON = ((gpio->GPGCON) & ~(3 << 24)) | (1 << 24); /* Output Mode */ gpio->GPGUP = (gpio->GPGUP) | ( 1 << 12); /* Pull up disable */ gpio->GPGDAT |= ( 1 << 12) ; gpio->GPGDAT &= ~( 1 << 12) ; udelay(20000); gpio->GPGDAT |= ( 1 << 12) ; #endif /* arch number of AESOP2440-Board */ gd->bd->bi_arch_number = MACH_TYPE_AESOP2440; /* ghcstop fix */ /* adress of boot parameters */ gd->bd->bi_boot_params = 0x30000100; icache_enable(); dcache_enable(); return 0;}#if 1unsigned char scratch[4096]; // buffer for SD read/writeunsigned int scratch1[4096]; // buffer for SD read/writeint SD_FS(void) // Check Partition table{ int MBR_exist; int i; MBR_exist=0; SD_Read(scratch, 0 , 1); //printf("SD Read #0 done\n"); if(scratch[511]==0xAA && scratch[510]==0x55) { if ( (scratch[450] == 0x01) || (scratch[450] == 0x04) || (scratch[450] == 0x06) || (scratch[450] == 0x0B) || /* FAT32 Partition */ (scratch[450] == 0x0C) || /* FAT32 Partition */ (scratch[450] == 0x55) ) /* FAT32 Partition */ MBR_exist=1; } if(MBR_exist) printf("(with MBR)\n\n"); else printf("(without MBR)\n\n");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -