From 39127ef8bfc4b94d499432a517ce7f8cdd63d3d5 Mon Sep 17 00:00:00 2001 From: Nicolas Thill Date: Fri, 27 Jul 2007 03:07:52 +0000 Subject: update ar7 to 2.6.22.1 (thanks to Matteo Croce for his great help) SVN-Revision: 8189 --- target/linux/ar7-2.6/files/arch/mips/ar7/memory.c | 119 ------------- .../linux/ar7-2.6/files/arch/mips/ar7/platform.c | 1 + target/linux/ar7-2.6/files/arch/mips/ar7/prom.c | 185 +++++++++------------ target/linux/ar7-2.6/files/arch/mips/ar7/setup.c | 3 + target/linux/ar7-2.6/files/drivers/net/cpmac.c | 6 +- .../linux/ar7-2.6/files/include/asm-mips/ar7/ar7.h | 7 +- .../ar7-2.6/files/include/asm-mips/ar7/prom.h | 1 - 7 files changed, 93 insertions(+), 229 deletions(-) (limited to 'target/linux/ar7-2.6/files') diff --git a/target/linux/ar7-2.6/files/arch/mips/ar7/memory.c b/target/linux/ar7-2.6/files/arch/mips/ar7/memory.c index 8ff571ce27..99faf217b7 100644 --- a/target/linux/ar7-2.6/files/arch/mips/ar7/memory.c +++ b/target/linux/ar7-2.6/files/arch/mips/ar7/memory.c @@ -60,132 +60,13 @@ static int __init memsize(void) return size; } -#ifdef CONFIG_NEED_MULTIPLE_NODES -static bootmem_data_t node_bootmem_data; -pg_data_t __node_data[1] = { - { - .bdata = &node_bootmem_data - }, -}; -EXPORT_SYMBOL(__node_data); - -unsigned long max_mapnr; -struct page *mem_map; -EXPORT_SYMBOL(max_mapnr); -EXPORT_SYMBOL(mem_map); - -static unsigned long setup_zero_pages(void) -{ - unsigned int order = 3; - unsigned long size; - struct page *page; - - empty_zero_page = __get_free_pages(GFP_KERNEL | __GFP_ZERO, order); - if (!empty_zero_page) - panic("Oh boy, that early out of memory?"); - - page = virt_to_page(empty_zero_page); - split_page(page, order); - while (page < virt_to_page(empty_zero_page + (PAGE_SIZE << order))) { - SetPageReserved(page); - page++; - } - - size = PAGE_SIZE << order; - zero_page_mask = (size - 1) & PAGE_MASK; - - return 1UL << order; -} - -extern void pagetable_init(void); - -void __init paging_init(void) -{ - unsigned long zones_size[MAX_NR_ZONES] = { 0, }; - - pagetable_init(); - - zones_size[ZONE_DMA] = max_low_pfn - min_low_pfn; - - free_area_init_node(0, NODE_DATA(0), zones_size, ARCH_PFN_OFFSET, NULL); -} - -static struct kcore_list kcore_mem, kcore_vmalloc; - -void __init mem_init(void) -{ - unsigned long codesize, reservedpages, datasize, initsize; - unsigned long tmp, ram; - unsigned long kernel_start, kernel_end; - - kernel_start = PFN_DOWN(CPHYSADDR((unsigned long)&_text)); - kernel_end = PFN_UP(CPHYSADDR((unsigned long)&_end)); - for (tmp = min_low_pfn + 1; tmp < kernel_start; tmp++) { - ClearPageReserved(pfn_to_page(tmp)); - init_page_count(pfn_to_page(tmp)); - free_page((unsigned long)__va(tmp << PAGE_SHIFT)); - } - - totalram_pages += free_all_bootmem(); - totalram_pages -= setup_zero_pages(); /* Setup zeroed pages. */ - - reservedpages = ram = 0; - for (tmp = min_low_pfn; tmp <= max_low_pfn; tmp++) { - ram++; - if (PageReserved(pfn_to_page(tmp))) - if ((tmp < kernel_start) || (tmp > kernel_end)) - reservedpages++; - } - num_physpages = ram; - - codesize = (unsigned long) &_etext - (unsigned long) &_text; - datasize = (unsigned long) &_edata - (unsigned long) &_etext; - initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin; - - kclist_add(&kcore_mem, __va(min_low_pfn), - (max_low_pfn - min_low_pfn) << PAGE_SHIFT); - kclist_add(&kcore_vmalloc, (void *)VMALLOC_START, - VMALLOC_END - VMALLOC_START); - - printk(KERN_INFO "Memory: %luk/%luk available (%ldk kernel code, " - "%ldk reserved, %ldk data, %ldk init)\n", - (unsigned long) nr_free_pages() << (PAGE_SHIFT-10), - ram << (PAGE_SHIFT-10), - codesize >> 10, - reservedpages << (PAGE_SHIFT-10), - datasize >> 10, - initsize >> 10); -} -#endif - void __init prom_meminit(void) { unsigned long pages; -#ifdef CONFIG_NEED_MULTIPLE_NODES - unsigned long kernel_start, kernel_end; - unsigned long free_pages; - unsigned long bootmap_size; -#endif pages = memsize() >> PAGE_SHIFT; add_memory_region(ARCH_PFN_OFFSET << PAGE_SHIFT, pages << PAGE_SHIFT, BOOT_MEM_RAM); - -#ifdef CONFIG_NEED_MULTIPLE_NODES - kernel_start = PFN_DOWN(CPHYSADDR((unsigned long)&_text)); - kernel_end = PFN_UP(CPHYSADDR((unsigned long)&_end)); - min_low_pfn = ARCH_PFN_OFFSET; - max_low_pfn = ARCH_PFN_OFFSET + pages; - max_mapnr = max_low_pfn; - free_pages = pages - (kernel_end - min_low_pfn); - bootmap_size = init_bootmem_node(NODE_DATA(0), kernel_end, - ARCH_PFN_OFFSET, max_low_pfn); - - free_bootmem(PFN_PHYS(kernel_end), free_pages << PAGE_SHIFT); - memory_present(0, min_low_pfn, max_low_pfn); - reserve_bootmem(PFN_PHYS(kernel_end), bootmap_size); - mem_map = NODE_DATA(0)->node_mem_map; -#endif } void __init prom_free_prom_memory(void) diff --git a/target/linux/ar7-2.6/files/arch/mips/ar7/platform.c b/target/linux/ar7-2.6/files/arch/mips/ar7/platform.c index c61e20a6c1..b9f7d0e9f9 100644 --- a/target/linux/ar7-2.6/files/arch/mips/ar7/platform.c +++ b/target/linux/ar7-2.6/files/arch/mips/ar7/platform.c @@ -32,6 +32,7 @@ #include #include #include +#include #include struct plat_vlynq_data { diff --git a/target/linux/ar7-2.6/files/arch/mips/ar7/prom.c b/target/linux/ar7-2.6/files/arch/mips/ar7/prom.c index 08904dee71..28397427d0 100644 --- a/target/linux/ar7-2.6/files/arch/mips/ar7/prom.c +++ b/target/linux/ar7-2.6/files/arch/mips/ar7/prom.c @@ -33,6 +33,7 @@ #include #include +#include #define MAX_ENTRY 80 @@ -41,72 +42,6 @@ struct env_var { char *value; }; -struct psp_chip_map { - u16 chip; - char *names[50]; -}; - -/* I hate this. No. *I* *HATE* *THIS* */ -static __initdata struct psp_chip_map psp_chip_map[] = { - { - .chip = AR7_CHIP_7100, - .names = { - "dummy", "cpufrequency", "memsize", - "flashsize", "modetty0", "modetty1", "prompt", - "bootcfg", "maca", "macb", "usb_rndis_mac", - "macap", "my_ipaddress", "server_ipaddress", - "bline_maca", "bline_macb", "bline_rndis", - "bline_atm", "usb_pid", "usb_vid", - "usb_eppolli", "gateway_ipaddress", - "subnet_mask", "usb_serial", "usb_board_mac", - "remote_user", "remote_pass", "remote_dir", - "sysfrequency", "link_timeout", "mac_port", - "path", "hostname", "tftpcfg", "buildops", - "tftp_fo_fname", "tftp_fo_ports", - "console_state", "mipsfrequency", - }, - }, - { - .chip = AR7_CHIP_7200, - .names = { - "dummy", "cpufrequency", "memsize", - "flashsize", "modetty0", "modetty1", "prompt", - "bootcfg", "maca", "macb", "usb_rndis_mac", - "macap", "my_ipaddress", "server_ipaddress", - "bline_maca", "bline_macb", "bline_rndis", - "bline_atm", "usb_pid", "usb_vid", - "usb_eppolli", "gateway_ipaddress", - "subnet_mask", "usb_serial", "usb_board_mac", - "remote_user", "remote_pass", "remote_dir", - "sysfrequency", "link_timeout", "mac_port", - "path", "hostname", "tftpcfg", "buildops", - "tftp_fo_fname", "tftp_fo_ports", - "console_state", "mipsfrequency", - }, - }, - { - .chip = AR7_CHIP_7300, - .names = { - "dummy", "cpufrequency", "memsize", - "flashsize", "modetty0", "modetty1", "prompt", - "bootcfg", "maca", "macb", "usb_rndis_mac", - "macap", "my_ipaddress", "server_ipaddress", - "bline_maca", "bline_macb", "bline_rndis", - "bline_atm", "usb_pid", "usb_vid", - "usb_eppolli", "gateway_ipaddress", - "subnet_mask", "usb_serial", "usb_board_mac", - "remote_user", "remote_pass", "remote_dir", - "sysfrequency", "link_timeout", "mac_port", - "path", "hostname", "tftpcfg", "buildops", - "tftp_fo_fname", "tftp_fo_ports", - "console_state", "mipsfrequency", - }, - }, - { - .chip = 0x0, - }, -}; - static struct env_var adam2_env[MAX_ENTRY] = { { 0, }, }; char * prom_getenv(char *name) @@ -155,15 +90,71 @@ struct psbl_rec { static __initdata char psp_env_version[] = "TIENV0.8"; -struct psp_env_var { - unsigned char num; - unsigned char ctrl; - unsigned short csum; - unsigned char len; - unsigned char data[11]; +struct psp_env_chunk { + u8 num; + u8 ctrl; + u16 csum; + u8 len; + char data[11]; +} __attribute__ ((packed)); + +struct psp_var_map_entry { + u8 num; + char *value; +}; + +static struct psp_var_map_entry psp_var_map[] = { + { 1, "cpufrequency" }, + { 2, "memsize" }, + { 3, "flashsize" }, + { 4, "modetty0" }, + { 5, "modetty1" }, + { 8, "maca" }, + { 9, "macb" }, + { 28, "sysfrequency" }, + { 38, "mipsfrequency" }, }; -static char psp_env_data[2048] = { 0, }; +/* + +Well-known variable (num is looked up in table above for matching variable name) +Example: cpufrequency=211968000 ++----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ +| 01 |CTRL|CHECKSUM | 01 | _2 | _1 | _1 | _9 | _6 | _8 | _0 | _0 | _0 | \0 | FF | ++----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ + +Name=Value pair in a single chunk +Example: NAME=VALUE ++----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ +| 00 |CTRL|CHECKSUM | 01 | _N | _A | _M | _E | _0 | _V | _A | _L | _U | _E | \0 | ++----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ + +Name=Value pair in 2 chunks (len is the number of chunks) +Example: bootloaderVersion=1.3.7.15 ++----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ +| 00 |CTRL|CHECKSUM | 02 | _b | _o | _o | _t | _l | _o | _a | _d | _e | _r | _V | ++----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ +| _e | _r | _s | _i | _o | _n | \0 | _1 | _. | _3 | _. | _7 | _. | _1 | _5 | \0 | ++----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ + +Data is padded with 0xFF + +*/ + +#define PSP_ENV_SIZE 4096 + +static char psp_env_data[PSP_ENV_SIZE] = { 0, }; + +static char * __init lookup_psp_var_map(u8 num) +{ + int i; + + for (i = 0; i < sizeof(psp_var_map); i++) + if (psp_var_map[i].num == num) + return psp_var_map[i].value; + + return NULL; +} static void __init add_adam2_var(char *name, char *value) { @@ -180,41 +171,29 @@ static void __init add_adam2_var(char *name, char *value) } } -static int __init parse_psp_env(void *start) +static int __init parse_psp_env(void *psp_env_base) { - int i, j; - u16 chip; - struct psp_chip_map *map; - char *src, *dest, *name, *value; - struct psp_env_var *vars = start; - - chip = ar7_chip_id(); - for (map = psp_chip_map; map->chip; map++) - if (map->chip == chip) - break; + int i, n; + char *name, *value; + struct psp_env_chunk *chunks = (struct psp_env_chunk *)psp_env_data; - if (!map->chip) - return -EINVAL; + memcpy_fromio(chunks, psp_env_base, PSP_ENV_SIZE); i = 1; - j = 0; - dest = psp_env_data; - while (vars[i].num < 0xff) { - src = vars[i].data; - if (vars[i].num) { - strcpy(dest, map->names[vars[i].num]); - name = dest; + n = PSP_ENV_SIZE / sizeof(struct psp_env_chunk); + while (i < n) { + if ((chunks[i].num == 0xff) || ((i + chunks[i].len) > n)) + break; + value = chunks[i].data; + if (chunks[i].num) { + name = lookup_psp_var_map(chunks[i].num); } else { - strcpy(dest, src); - name = dest; - src += strlen(src) + 1; - } - dest += strlen(dest) + 1; - strcpy(dest, src); - value = dest; - dest += strlen(dest) + 1; - add_adam2_var(name, value); - i += vars[i].len; + name = value; + value += strlen(name) + 1; + } + if (name) + add_adam2_var(name, value); + i += chunks[i].len; } return 0; } diff --git a/target/linux/ar7-2.6/files/arch/mips/ar7/setup.c b/target/linux/ar7-2.6/files/arch/mips/ar7/setup.c index 6c9c1bf7bd..4abc39f1df 100644 --- a/target/linux/ar7-2.6/files/arch/mips/ar7/setup.c +++ b/target/linux/ar7-2.6/files/arch/mips/ar7/setup.c @@ -116,6 +116,9 @@ void __init plat_mem_setup(void) ioport_resource.end = ~0; iomem_resource.start = 0; iomem_resource.end = ~0; + + printk("%s, ID: 0x%04x, Revision: 0x%02x\n", get_system_type(), + ar7_chip_id(), ar7_chip_rev()); } console_initcall(ar7_init_console); diff --git a/target/linux/ar7-2.6/files/drivers/net/cpmac.c b/target/linux/ar7-2.6/files/drivers/net/cpmac.c index 1be7cb8ddd..7d46677080 100644 --- a/target/linux/ar7-2.6/files/drivers/net/cpmac.c +++ b/target/linux/ar7-2.6/files/drivers/net/cpmac.c @@ -1173,9 +1173,9 @@ int __devinit cpmac_init(void) #warning FIXME: unhardcode gpio&reset bits ar7_gpio_disable(26); ar7_gpio_disable(27); - ar7_device_reset(17); - ar7_device_reset(21); - ar7_device_reset(26); + ar7_device_reset(AR7_RESET_BIT_CPMAC_LO); + ar7_device_reset(AR7_RESET_BIT_CPMAC_HI); + ar7_device_reset(AR7_RESET_BIT_EPHY); cpmac_mii.reset(&cpmac_mii); diff --git a/target/linux/ar7-2.6/files/include/asm-mips/ar7/ar7.h b/target/linux/ar7-2.6/files/include/asm-mips/ar7/ar7.h index 3e6a50c324..e8e32a0b83 100644 --- a/target/linux/ar7-2.6/files/include/asm-mips/ar7/ar7.h +++ b/target/linux/ar7-2.6/files/include/asm-mips/ar7/ar7.h @@ -53,7 +53,10 @@ #define AR7_RESET_SOFTWARE 0x4 #define AR7_RESET_STATUS 0x8 -#define AR7_RESET_BIT_MDIO 22 +#define AR7_RESET_BIT_CPMAC_LO 17 +#define AR7_RESET_BIT_CPMAC_HI 21 +#define AR7_RESET_BIT_MDIO 22 +#define AR7_RESET_BIT_EPHY 26 /* GPIO control registers */ #define AR7_GPIO_INPUT 0x0 @@ -83,8 +86,6 @@ struct plat_dsl_data { int reset_bit_sar; }; -extern char *prom_getenv(char *envname); - extern int ar7_cpu_clock, ar7_bus_clock, ar7_dsp_clock; static inline u16 ar7_chip_id(void) diff --git a/target/linux/ar7-2.6/files/include/asm-mips/ar7/prom.h b/target/linux/ar7-2.6/files/include/asm-mips/ar7/prom.h index bb0b0c4d5b..10d6235102 100644 --- a/target/linux/ar7-2.6/files/include/asm-mips/ar7/prom.h +++ b/target/linux/ar7-2.6/files/include/asm-mips/ar7/prom.h @@ -21,7 +21,6 @@ #ifndef __PROM_H__ #define __PROM_H__ -extern void prom_init(void); extern char *prom_getenv(char *name); extern void prom_printf(char *fmt, ...); -- cgit v1.2.3