diff options
Diffstat (limited to 'target/linux/ar7')
22 files changed, 1308 insertions, 0 deletions
diff --git a/target/linux/ar7/Makefile b/target/linux/ar7/Makefile new file mode 100644 index 000000000..a712d6d20 --- /dev/null +++ b/target/linux/ar7/Makefile @@ -0,0 +1,26 @@ +# +# Copyright (C) 2006-2011 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +include $(TOPDIR)/rules.mk + +ARCH:=mipsel +BOARD:=ar7 +BOARDNAME:=TI AR7 +FEATURES:=squashfs jffs2 atm +MAINTAINER:=Florian Fainelli <florian@openwrt.org> + +LINUX_VERSION:=3.3.8 + +include $(INCLUDE_DIR)/target.mk + +DEFAULT_PACKAGES+= kmod-pppoa ppp-mod-pppoa linux-atm atm-tools br2684ctl \ + kmod-acx-mac80211 swconfig hostapd + +define Target/Description + Build firmware images for TI AR7 based routers. +endef + +$(eval $(call BuildTarget)) diff --git a/target/linux/ar7/base-files.mk b/target/linux/ar7/base-files.mk new file mode 100644 index 000000000..f21a604b8 --- /dev/null +++ b/target/linux/ar7/base-files.mk @@ -0,0 +1,11 @@ +define Build/Compile + $(call Build/Compile/Default) + $(TARGET_CC) -o $(PKG_BUILD_DIR)/adam2patcher $(PLATFORM_DIR)/src/adam2patcher.c +endef + +define Package/base-files/install-target + mkdir -p $(1)/sbin + $(CP) $(PKG_BUILD_DIR)/adam2patcher $(1)/sbin +endef + + diff --git a/target/linux/ar7/base-files/etc/config/network b/target/linux/ar7/base-files/etc/config/network new file mode 100644 index 000000000..9ba0e6d29 --- /dev/null +++ b/target/linux/ar7/base-files/etc/config/network @@ -0,0 +1,42 @@ +# Copyright (C) 2006 OpenWrt.org + +config interface loopback + option ifname lo + option proto static + option ipaddr 127.0.0.1 + option netmask 255.0.0.0 + +config interface lan + option type bridge + option ifname "eth0 eth1" + option proto static + option ipaddr 192.168.1.1 + option netmask 255.255.255.0 + option nat 1 + +## Example for ATM bridging. +## Useful for PPPoE or IP over ATM. Will create 'nas${unit}' +# +# config atm-bridge +# option unit 0 +# option encaps llc +# option vpi 8 +# option vci 35 +# option payload bridged # some ISPs need this set to 'routed' + + +# config interface wan +## PPPoE: +# option ifname nas0 +# option proto pppoe + +## PPPoA: +# option ifname atm0 +# option proto pppoa +# option encaps llc +# option vpi 8 +# option vci 35 + +## Both: +# option username "my_username" +# option password "my_password" diff --git a/target/linux/ar7/base-files/etc/diag.sh b/target/linux/ar7/base-files/etc/diag.sh new file mode 100644 index 000000000..b8e4dc874 --- /dev/null +++ b/target/linux/ar7/base-files/etc/diag.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Copyright (C) 2007 OpenWrt.org + +# This setup gives us 4.5 distinguishable states: +# +# Solid OFF: Bootloader running, or kernel hung (timer task stalled) +# Solid ON: Kernel hung (timer task stalled) +# 5Hz blink: preinit +# 10Hz blink: failsafe +# Heartbeat: normal operation + +set_state() { + case "$1" in + preinit) + [ -d /sys/class/leds/status ] && { + echo timer >/sys/class/leds/status/trigger + echo 100 >/sys/class/leds/status/delay_on + echo 100 >/sys/class/leds/status/delay_off + } + ;; + failsafe) + [ -d /sys/class/leds/status ] && { + echo timer >/sys/class/leds/status/trigger + echo 50 >/sys/class/leds/status/delay_on + echo 50 >/sys/class/leds/status/delay_off + } + ;; + done) + [ -d /sys/class/leds/status ] && { + echo heartbeat >/sys/class/leds/status/trigger + } + ;; + esac +} diff --git a/target/linux/ar7/base-files/etc/init.d/adam2 b/target/linux/ar7/base-files/etc/init.d/adam2 new file mode 100755 index 000000000..6b786270e --- /dev/null +++ b/target/linux/ar7/base-files/etc/init.d/adam2 @@ -0,0 +1,13 @@ +#!/bin/sh /etc/rc.common +# ADAM2 patcher for Netgear DG834 and compatible +# Copyright (C) 2006 OpenWrt.org + +START=00 +start() { + MD5="$(md5sum /dev/mtdblock0 | awk '{print $1}')" + [ "$MD5" = "0530bfdf00ec155f4182afd70da028c1" ] && { + mtd unlock adam2 + /sbin/adam2patcher /dev/mtdblock0 + } + rm -f /etc/rc.d/S${START}adam2 /etc/init.d/adam2 /sbin/adam2patcher >&- 2>&- +} diff --git a/target/linux/ar7/base-files/etc/uci-defaults/network b/target/linux/ar7/base-files/etc/uci-defaults/network new file mode 100644 index 000000000..2d35c56b1 --- /dev/null +++ b/target/linux/ar7/base-files/etc/uci-defaults/network @@ -0,0 +1,30 @@ +#!/bin/sh +if [ -e "/sys/bus/mdio_bus/drivers/IC+ IP175A/1:00" -o \ + -e "/sys/bus/mdio_bus/drivers/IC+ IP17xx/1:00" ] && \ + [ -x /sbin/swconfig ]; +then + uci batch <<EOF +set network.eth0=switch +set network.eth0.name=eth0 +set network.eth0.reset=1 +set network.eth0.enable_vlan=1 +set network.eth0_1=switch_vlan +set network.eth0_1.device=eth0 +set network.eth0_1.vlan=1 +set network.eth0_1.ports="0 1 2 3 4t" +commit network +EOF + HAS_SWITCH=1 +fi + +if [ -n "$HAS_SWITCH" -o \ + -e "/sys/bus/mdio_bus/drivers/Infineon ADM6996/1:00" -o \ + -e "/sys/bus/mdio_bus/drivers/Marvell 88E6060/1:10" ]; then + uci batch <<EOF +set network.lan.ifname=eth0.1 +commit network +EOF + HAS_SWITCH=1 +fi + +uci commit network diff --git a/target/linux/ar7/config-3.3 b/target/linux/ar7/config-3.3 new file mode 100644 index 000000000..9ba049741 --- /dev/null +++ b/target/linux/ar7/config-3.3 @@ -0,0 +1,99 @@ +CONFIG_ADM6996_PHY=y +CONFIG_AR7=y +CONFIG_AR7_GPIO=y +CONFIG_AR7_WDT=y +CONFIG_ARCH_BINFMT_ELF_RANDOMIZE_PIE=y +CONFIG_ARCH_DISCARD_MEMBLOCK=y +CONFIG_ARCH_HIBERNATION_POSSIBLE=y +CONFIG_ARCH_REQUIRE_GPIOLIB=y +CONFIG_ARCH_SUSPEND_POSSIBLE=y +CONFIG_BCMA_POSSIBLE=y +CONFIG_BOOT_ELF32=y +CONFIG_CEVT_R4K=y +CONFIG_CEVT_R4K_LIB=y +CONFIG_CPMAC=y +CONFIG_CPU_HAS_PREFETCH=y +CONFIG_CPU_HAS_SYNC=y +CONFIG_CPU_LITTLE_ENDIAN=y +CONFIG_CPU_MIPS32=y +CONFIG_CPU_MIPS32_R1=y +CONFIG_CPU_MIPSR1=y +CONFIG_CPU_SUPPORTS_32BIT_KERNEL=y +CONFIG_CPU_SUPPORTS_HIGHMEM=y +CONFIG_CSRC_R4K=y +CONFIG_CSRC_R4K_LIB=y +# CONFIG_DEBUG_ZBOOT is not set +CONFIG_DECOMPRESS_LZMA=y +CONFIG_DMA_NONCOHERENT=y +CONFIG_EARLY_PRINTK=y +CONFIG_FIXED_PHY=y +CONFIG_GENERIC_ATOMIC64=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_GENERIC_CLOCKEVENTS_BUILD=y +CONFIG_GENERIC_CMOS_UPDATE=y +CONFIG_GENERIC_GPIO=y +CONFIG_GENERIC_IRQ_SHOW=y +CONFIG_GPIOLIB=y +CONFIG_HARDWARE_WATCHPOINTS=y +CONFIG_HAS_DMA=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT=y +CONFIG_HAVE_ARCH_JUMP_LABEL=y +CONFIG_HAVE_ARCH_KGDB=y +CONFIG_HAVE_C_RECORDMCOUNT=y +CONFIG_HAVE_DMA_API_DEBUG=y +CONFIG_HAVE_DMA_ATTRS=y +CONFIG_HAVE_DYNAMIC_FTRACE=y +CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y +CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y +CONFIG_HAVE_FUNCTION_TRACER=y +CONFIG_HAVE_FUNCTION_TRACE_MCOUNT_TEST=y +CONFIG_HAVE_GENERIC_DMA_COHERENT=y +CONFIG_HAVE_GENERIC_HARDIRQS=y +CONFIG_HAVE_IDE=y +CONFIG_HAVE_IRQ_WORK=y +CONFIG_HAVE_KERNEL_BZIP2=y +CONFIG_HAVE_KERNEL_GZIP=y +CONFIG_HAVE_KERNEL_LZMA=y +CONFIG_HAVE_KERNEL_LZO=y +CONFIG_HAVE_MEMBLOCK=y +CONFIG_HAVE_MEMBLOCK_NODE_MAP=y +CONFIG_HAVE_OPROFILE=y +CONFIG_HAVE_PERF_EVENTS=y +CONFIG_HW_RANDOM=y +CONFIG_INITRAMFS_SOURCE="" +CONFIG_IP17XX_PHY=y +CONFIG_IRQ_CPU=y +CONFIG_IRQ_FORCED_THREADING=y +CONFIG_KALLSYMS=y +CONFIG_KERNEL_GZIP=y +CONFIG_LEDS_GPIO=y +CONFIG_MDIO_BOARDINFO=y +CONFIG_MIPS=y +CONFIG_MIPS_L1_CACHE_SHIFT=5 +# CONFIG_MIPS_MACHINE is not set +CONFIG_MIPS_MT_DISABLED=y +CONFIG_MTD_AR7_PARTS=y +CONFIG_MTD_CFI_STAA=y +CONFIG_MTD_PHYSMAP=y +CONFIG_NEED_DMA_MAP_STATE=y +CONFIG_NEED_PER_CPU_KM=y +CONFIG_NO_EXCEPT_FILL=y +CONFIG_PAGEFLAGS_EXTENDED=y +CONFIG_PERF_USE_VMALLOC=y +CONFIG_PHYLIB=y +# CONFIG_PREEMPT_RCU is not set +# CONFIG_SCSI_DMA is not set +CONFIG_SWAP_IO_SPACE=y +CONFIG_SWCONFIG=y +CONFIG_SYS_HAS_CPU_MIPS32_R1=y +CONFIG_SYS_HAS_EARLY_PRINTK=y +CONFIG_SYS_SUPPORTS_32BIT_KERNEL=y +CONFIG_SYS_SUPPORTS_ARBIT_HZ=y +CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y +CONFIG_SYS_SUPPORTS_ZBOOT=y +CONFIG_SYS_SUPPORTS_ZBOOT_UART16550=y +CONFIG_VLYNQ=y +# CONFIG_VLYNQ_DEBUG is not set +CONFIG_XZ_DEC=y +CONFIG_ZONE_DMA_FLAG=0 diff --git a/target/linux/ar7/files/drivers/char/ar7_gpio.c b/target/linux/ar7/files/drivers/char/ar7_gpio.c new file mode 100644 index 000000000..a7d0a5534 --- /dev/null +++ b/target/linux/ar7/files/drivers/char/ar7_gpio.c @@ -0,0 +1,158 @@ +/* + * Copyright (C) 2007 Nicolas Thill <nico@openwrt.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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <linux/device.h> +#include <linux/fs.h> +#include <linux/module.h> +#include <linux/errno.h> +#include <linux/kernel.h> +#include <linux/init.h> +#include <linux/platform_device.h> +#include <linux/uaccess.h> +#include <linux/io.h> +#include <linux/types.h> +#include <linux/cdev.h> +#include <gpio.h> + +#define DRVNAME "ar7_gpio" +#define LONGNAME "TI AR7 GPIOs Driver" + +MODULE_AUTHOR("Nicolas Thill <nico@openwrt.org>"); +MODULE_DESCRIPTION(LONGNAME); +MODULE_LICENSE("GPL"); + +static int ar7_gpio_major; + +static ssize_t ar7_gpio_write(struct file *file, const char __user *buf, + size_t len, loff_t *ppos) +{ + int pin = iminor(file->f_dentry->d_inode); + size_t i; + + for (i = 0; i < len; ++i) { + char c; + if (get_user(c, buf + i)) + return -EFAULT; + switch (c) { + case '0': + gpio_set_value(pin, 0); + break; + case '1': + gpio_set_value(pin, 1); + break; + case 'd': + case 'D': + ar7_gpio_disable(pin); + break; + case 'e': + case 'E': + ar7_gpio_enable(pin); + break; + case 'i': + case 'I': + case '<': + gpio_direction_input(pin); + break; + case 'o': + case 'O': + case '>': + gpio_direction_output(pin, 0); + break; + default: + return -EINVAL; + } + } + + return len; +} + +static ssize_t ar7_gpio_read(struct file *file, char __user *buf, + size_t len, loff_t *ppos) +{ + int pin = iminor(file->f_dentry->d_inode); + int value; + + value = gpio_get_value(pin); + if (put_user(value ? '1' : '0', buf)) + return -EFAULT; + + return 1; +} + +static int ar7_gpio_open(struct inode *inode, struct file *file) +{ + int m = iminor(inode); + + if (m >= (ar7_is_titan() ? TITAN_GPIO_MAX : AR7_GPIO_MAX)) + return -EINVAL; + + return nonseekable_open(inode, file); +} + +static int ar7_gpio_release(struct inode *inode, struct file *file) +{ + return 0; +} + +static const struct file_operations ar7_gpio_fops = { + .owner = THIS_MODULE, + .write = ar7_gpio_write, + .read = ar7_gpio_read, + .open = ar7_gpio_open, + .release = ar7_gpio_release, + .llseek = no_llseek, +}; + +static struct platform_device *ar7_gpio_device; + +static int __init ar7_gpio_char_init(void) +{ + int rc; + + ar7_gpio_device = platform_device_alloc(DRVNAME, -1); + if (!ar7_gpio_device) + return -ENOMEM; + + rc = platform_device_add(ar7_gpio_device); + if (rc < 0) + goto out_put; + + rc = register_chrdev(ar7_gpio_major, DRVNAME, &ar7_gpio_fops); + if (rc < 0) + goto out_put; + + ar7_gpio_major = rc; + + rc = 0; + + goto out; + +out_put: + platform_device_put(ar7_gpio_device); +out: + return rc; +} + +static void __exit ar7_gpio_char_exit(void) +{ + unregister_chrdev(ar7_gpio_major, DRVNAME); + platform_device_unregister(ar7_gpio_device); +} + +module_init(ar7_gpio_char_init); +module_exit(ar7_gpio_char_exit); diff --git a/target/linux/ar7/files/drivers/mtd/titanpart.c b/target/linux/ar7/files/drivers/mtd/titanpart.c new file mode 100644 index 000000000..74f8251a2 --- /dev/null +++ b/target/linux/ar7/files/drivers/mtd/titanpart.c @@ -0,0 +1,234 @@ +#include <linux/kernel.h> +#include <linux/slab.h> + +#include <linux/mtd/mtd.h> +#include <linux/mtd/partitions.h> +#include <linux/bootmem.h> +#include <linux/magic.h> +#include <asm/mach-ar7/prom.h> + +#define IMAGE_A_SIZE 0X3c0000 +#define WRTP_PARTS 14 +#define NSP_IMG_MAGIC_NUMBER le32_to_cpu(0x4D544443) +#define NSP_IMG_SECTION_TYPE_KERNEL (0x01) +#define NSP_IMG_SECTION_TYPE_FILESYSTEM_ROOT (0x02) +#define NSP_IMG_SECTION_TYPE_FILESYSTEM (0x03) +#define MAX_NUM_PARTITIONS 14 + +static int part_count=0; +static struct mtd_partition titan_parts[WRTP_PARTS]; + + +struct nsp_img_hdr_head +{ + unsigned int magic; /* Magic number to identify this image header */ + unsigned int boot_offset; /* Offset from start of header to kernel code. */ + unsigned int flags; /* Image flags. */ + unsigned int hdr_version; /* Version of this header. */ + unsigned int hdr_size; /* The complete size of all portions of the header */ + unsigned int prod_id; /* This product id */ + unsigned int rel_id; /* Which release this is */ + unsigned int version; /* name-MMM.nnn.ooo-rxx => 0xMMnnooxx. See comment + below */ + unsigned int image_size; /* Image size (including header) */ + unsigned int info_offset; /* Offset from start of header to info block */ + unsigned int sect_info_offset; /* Offset from start of header to section desc */ + unsigned int chksum_offset; /* Offset from start of header to chksum block */ + unsigned int pad1; +}; + +struct nsp_img_hdr_section_info +{ + unsigned int num_sects; /* Number of section (and section desc blocks) in this image */ + unsigned int sect_size; /* Size of a SINGLE section_desc block */ + unsigned int sections_offset; /* Offset to from start of header to the start of the section blocks */ +}; + +/* There will be one of more of the following stuctures in the image header. Each + section will have one of these blocks. */ +struct nsp_img_hdr_sections +{ + unsigned int offset; /* Offset of section from start of NSP_IMG_HDR_HEAD */ + unsigned int total_size; /* Size of section (including pad size.) */ + unsigned int raw_size; /* Size of section only */ + unsigned int flags; /* Section flags */ + unsigned int chksum; /* Section checksum */ + unsigned int type; /* Section type. What kind of info does this section describe */ + char name[16]; /* Reference name for this section. */ +}; + + + + + +static int titan_parse_env_address(char *env_name, unsigned int *flash_base, + unsigned int *flash_end) +{ + char image_name[30]; + char *env_ptr; + char *base_ptr; + char *end_ptr; + char * string_ptr; + /* Get the image variable */ + env_ptr = prom_getenv(env_name); + if(!env_ptr){ + printk("titan: invalid env name, %s.\n", env_name); + return -1; /* Error, no image variable */ + } + strncpy(image_name, env_ptr, 30); + image_name[29]=0; + string_ptr = image_name; + /* Extract the start and stop addresses of the partition */ + base_ptr = strsep(&string_ptr, ","); + end_ptr = strsep(&string_ptr, ","); + if ((base_ptr == NULL) || (end_ptr == NULL)) { + printk("titan: Couldn't tokenize %s start,end.\n", image_name); + return -1; + } + + *flash_base = (unsigned int) simple_strtol(base_ptr, NULL, 0); + *flash_end = (unsigned int) simple_strtol(end_ptr, NULL, 0); + if((!*flash_base) || (!*flash_end)) { + printk("titan: Unable to convert :%s: :%s: into start,end values.\n", + env_name, image_name); + return -1; + } + *flash_base &= 0x0fffffff; + *flash_end &= 0x0fffffff; + return 0; +} + + + +static int titan_get_single_image(char *bootcfg_name, unsigned int *flash_base, + unsigned int *flash_end) +{ + char *env_ptr; + char *base_ptr; + char *end_ptr; + char image_name[30]; + char * string_ptr; + + if(!bootcfg_name || !flash_base || !flash_end) + return -1; + + env_ptr = prom_getenv(bootcfg_name); + if(!env_ptr){ + printk("titan: %s variable not found.\n", bootcfg_name); + return -1; /* Error, no bootcfg variable */ + } + + string_ptr = image_name; + /* Save off the image name */ + strncpy(image_name, env_ptr, 30); + image_name[29]=0; + + end_ptr=strsep(&string_ptr, "\""); + base_ptr=strsep(&string_ptr, "\""); /* Loose the last " */ + if(!end_ptr || !base_ptr){ + printk("titan: invalid bootcfg format, %s.\n", image_name); + return -1; /* Error, invalid bootcfg variable */ + } + + /* Now, parse the addresses */ + return titan_parse_env_address(base_ptr, flash_base, flash_end); +} + + + +static void titan_add_partition(char * env_name, unsigned int flash_base, unsigned int flash_end) +{ + titan_parts[part_count].name = env_name; + titan_parts[part_count].offset = flash_base; + titan_parts[part_count].size = flash_end-flash_base; + titan_parts[part_count].mask_flags = (strcmp(env_name, "bootloader")==0|| + strcmp(env_name, "boot_env")==0 || + strcmp(env_name, "full_image")==0 )?MTD_WRITEABLE:0; + part_count++; + +} +int create_titan_partitions(struct mtd_info *master, + struct mtd_partition **pparts, + unsigned long origin) +{ + struct nsp_img_hdr_head hdr; + struct nsp_img_hdr_section_info sect_info; + struct nsp_img_hdr_sections section; + unsigned int flash_base, flash_end; + unsigned int start, end; + char *name; + int i; + int total_sects=0; + size_t len; + + /* Get the bootcfg env variable first */ + if(titan_get_single_image("BOOTCFG", &flash_base, &flash_end)) { + /* Error, fallback */ + return -1; + } + + /* Get access to the header, and do some validation checks */ + //hdr=(struct nsp_img_hdr_head*)flash_base; + master->read(master, flash_base, sizeof(struct nsp_img_hdr_head), &len, (uint8_t *)&hdr); + if(hdr.magic != NSP_IMG_MAGIC_NUMBER) + return -1; /* Not a single image */ + + master->read(master, flash_base + hdr.sect_info_offset, sizeof(struct nsp_img_hdr_section_info), &len, (uint8_t *)§_info); + + /* Look for the root fs, and add it first. This way we KNOW where the rootfs is */ + for(i=0; i< sect_info.num_sects && i<MAX_NUM_PARTITIONS; i++){ + master->read(master, flash_base + sect_info.sections_offset + (i * sect_info.sect_size) , sizeof(struct nsp_img_hdr_sections), &len, (uint8_t *)§ion); + /* Add only the root partition */ + if(section.type != NSP_IMG_SECTION_TYPE_FILESYSTEM_ROOT){ + continue; + } + start=flash_base + section.offset; + end=start + section.total_size; + titan_add_partition("root", start, end); + total_sects++; + + } + + for(i=0; i< sect_info.num_sects && i<MAX_NUM_PARTITIONS; i++){ + + master->read(master, flash_base + sect_info.sections_offset + (i * sect_info.sect_size) , sizeof(struct nsp_img_hdr_sections), &len, (uint8_t *)§ion); + + name=section.name; + if(section.type == NSP_IMG_SECTION_TYPE_FILESYSTEM_ROOT) + { + name = "rootfs"; + start=flash_base + section.offset; + end=flash_end; + titan_add_partition(name, start, end); + total_sects++; + } + else if(section.type == NSP_IMG_SECTION_TYPE_KERNEL) + { + name = "kernel"; + start=flash_base + section.offset; + end=start + section.total_size; + titan_add_partition(name, start, end); + total_sects++; + } + + } + + /* Next, lets add the single image */ + titan_add_partition("primary_image", flash_base, flash_end); + total_sects++; + + + titan_add_partition("full_image", 0, master->size); + total_sects++; + + if (!titan_parse_env_address("BOOTLOADER", &start, &end)){ + titan_add_partition("bootloader", start, end); + total_sects++; + } + if (!titan_parse_env_address("boot_env", &start, &end)){ + titan_add_partition("boot_env", start, end); + total_sects++; + } + *pparts = titan_parts; + return total_sects; +} diff --git a/target/linux/ar7/image/Makefile b/target/linux/ar7/image/Makefile new file mode 100644 index 000000000..d27c2e888 --- /dev/null +++ b/target/linux/ar7/image/Makefile @@ -0,0 +1,109 @@ +# +# Copyright (C) 2006-2010 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/image.mk + +DROP_SECTIONS:=.reginfo .mdebug .comment .note .pdr .options .MIPS.options +OBJCOPY_SREC:=$(TARGET_CROSS)objcopy -S -O srec $(addprefix --remove-section=,$(DROP_SECTIONS)) + +LOADADDR:=0x94600000 +KERNEL_ENTRY:=0x94100000 +RAMSTART:=0x94000000 +RAMSIZE:=0x00100000 + +EVA_LOADADDR := 0x94100000 + +LOADER_MAKEOPTS= \ + KDIR=$(KDIR) \ + LOADADDR=$(LOADADDR) \ + KERNEL_ENTRY=$(KERNEL_ENTRY) \ + RAMSTART=$(RAMSTART) \ + RAMSIZE=$(RAMSIZE) + +CFLAGS := -D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -Os \ + -fno-strict-aliasing -fno-common -fomit-frame-pointer -G 0 -mno-abicalls -fno-pic \ + -pipe -mlong-calls -fno-common \ + -mabi=32 -march=mips32 -Wa,-32 -Wa,-march=mips32 -Wa,-mips32 -Wa,--trap \ + -DLOADADDR=$(LOADADDR) + +define Build/Clean + $(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader $(LOADER_MAKEOPTS) clean +endef + +define Image/Prepare + cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma + + $(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader \ + $(LOADER_MAKEOPTS) \ + clean compile + $(OBJCOPY_SREC) $(KDIR)/loader.elf $(KDIR)/loader.srec + srec2bin $(KDIR)/loader.srec $(KDIR)/loader.bin +endef + +define align/jffs2-64k +bs=65536 conv=sync +endef + +define align/jffs2-128k +bs=131072 conv=sync +endef + +define align/squashfs +bs=65536 conv=sync +endef + +define Image/Build/CyberTAN + (dd if=/dev/zero bs=16 count=1; cat $(BIN_DIR)/$(IMG_PREFIX)-$(1).bin) | \ + $(STAGING_DIR_HOST)/bin/addpattern -p $(3) -o $(BIN_DIR)/openwrt-$(2)-$(4)-code.bin +endef + +define Image/Build/Titan + $(STAGING_DIR_HOST)/bin/mktitanimg -o $(BIN_DIR)/openwrt-$(2)-$(4)-code.bin -i $(KDIR)/loader.bin $(KDIR)/root.$(1) -a 0x10000 0x10000 -h 2 -p 0x4C575943 -s 0x0b010000 + $(STAGING_DIR_HOST)/bin/mktitanimg -o $(BIN_DIR)/openwrt-$(2)-na-$(4)-code.bin -i $(KDIR)/loader.bin $(KDIR)/root.$(1) -a 0x10000 0x10000 -h 2 -p 0x4D575943 -s 0x0b010000 +endef + + +#define Image/Build/sErCoMm +# cat sercomm/adam2.bin "$(BIN_DIR)/$(IMG_PREFIX)-$(1).bin" > "$(KDIR)/dgfw.tmp" +# dd if=sercomm/$(2) of="$(KDIR)/dgfw.tmp" bs=$$$$((0x3e0000 - 80)) seek=1 conv=notrunc +# $(STAGING_DIR_HOST)/bin/dgfirmware -f -w "$(BIN_DIR)/openwrt-$(2)-$(3).img" "$(KDIR)/dgfw.tmp" +# rm -f "$(KDIR)/dgfw.tmp" +#endef + +define Image/Build/EVA + $(STAGING_DIR_HOST)/bin/lzma2eva $(EVA_LOADADDR) 0x$${shell $(TARGET_CROSS)nm $(KDIR)/linux-*/vmlinux | grep -w kernel_entry | cut -d' ' -f1} $(KDIR)/vmlinux.lzma $(KDIR)/loader.eva + dd if=$(KDIR)/loader.eva $(call align/$(1)) > $(BIN_DIR)/openwrt-$(2)-$(KERNEL)-$(1).bin + cat $(KDIR)/root.$(1) >> $(BIN_DIR)/openwrt-$(2)-$(KERNEL)-$(1).bin + $(call prepare_generic_squashfs,$(BIN_DIR)/openwrt-$(2)-$(KERNEL)-$(1).bin) +endef + +define Image/Build + dd if=$(KDIR)/loader.bin $(call align/$(1)) > $(BIN_DIR)/$(IMG_PREFIX)-$(1).bin + cat $(KDIR)/root.$(1) >> $(BIN_DIR)/$(IMG_PREFIX)-$(1).bin + $(call prepare_generic_squashfs,$(BIN_DIR)/$(IMG_PREFIX)-$(1).bin) + $(call Image/Build/CyberTAN,$(1),AG1B,AG1B,$(1)) + $(call Image/Build/CyberTAN,$(1),AG1A,AG1A,$(1)) + $(call Image/Build/CyberTAN,$(1),WA21,WA21,$(1)) + $(call Image/Build/CyberTAN,$(1),WA22,WA22,$(1)) + $(call Image/Build/CyberTAN,$(1),WAG2,WAG2,$(1)) + $(call Image/Build/CyberTAN,$(1),AG310,AV2A -b -r 1.0,$(1)) + $(call Image/Build/CyberTAN,$(1),AG241v2,AG3A -b -r 2.0,$(1)) + $(call Image/Build/CyberTAN,$(1),AG241v2b,AG3B -b -r 2.0,$(1)) + $(call Image/Build/CyberTAN,$(1),AG241v1,AG3A -b,$(1)) + $(call Image/Build/CyberTAN,$(1),WAG54GP2v1,ATWL -b,$(1)) + $(call Image/Build/CyberTAN,$(1),WAG54GP2v2,CTWL -b,$(1)) + $(call Image/Build/CyberTAN,$(1),WA31,WA31 -b,$(1)) + $(call Image/Build/CyberTAN,$(1),WA32,WA32 -b,$(1)) + $(call Image/Build/CyberTAN,$(1),WA7A,WA7A -b,$(1)) + $(call Image/Build/CyberTAN,$(1),WA7B,WA7B -b,$(1)) +# $(call Image/Build/sErCoMm,$(1),dg834,$(1)) +# $(call Image/Build/sErCoMm,$(1),jdr454wb,$(1)) + $(call Image/Build/EVA,$(1),EVA) + $(call Image/Build/Titan,$(1),Titan,Titan,$(1)) +endef + +$(eval $(call BuildImage)) diff --git a/target/linux/ar7/patches-3.3/110-flash.patch b/target/linux/ar7/patches-3.3/110-flash.patch new file mode 100644 index 000000000..58ce7eaa4 --- /dev/null +++ b/target/linux/ar7/patches-3.3/110-flash.patch @@ -0,0 +1,22 @@ +--- a/drivers/mtd/maps/physmap.c ++++ b/drivers/mtd/maps/physmap.c +@@ -78,7 +78,7 @@ static const char *rom_probe_types[] = { + "map_rom", + NULL }; + static const char *part_probe_types[] = { "cmdlinepart", "RedBoot", "afs", +- NULL }; ++ "ar7part", NULL }; + + static int physmap_flash_probe(struct platform_device *dev) + { +--- a/drivers/mtd/Makefile ++++ b/drivers/mtd/Makefile +@@ -10,7 +10,7 @@ obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o + obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o + obj-$(CONFIG_MTD_CMDLINE_PARTS) += cmdlinepart.o + obj-$(CONFIG_MTD_AFS_PARTS) += afs.o +-obj-$(CONFIG_MTD_AR7_PARTS) += ar7part.o ++obj-$(CONFIG_MTD_AR7_PARTS) += ar7part.o titanpart.o + obj-$(CONFIG_MTD_BCM63XX_PARTS) += bcm63xxpart.o + obj-$(CONFIG_MTD_MYLOADER_PARTS) += myloader.o + diff --git a/target/linux/ar7/patches-3.3/120-gpio_chrdev.patch b/target/linux/ar7/patches-3.3/120-gpio_chrdev.patch new file mode 100644 index 000000000..006cef4d5 --- /dev/null +++ b/target/linux/ar7/patches-3.3/120-gpio_chrdev.patch @@ -0,0 +1,28 @@ +--- a/drivers/char/Kconfig ++++ b/drivers/char/Kconfig +@@ -478,6 +478,15 @@ config MWAVE + To compile this driver as a module, choose M here: the + module will be called mwave. + ++config AR7_GPIO ++ tristate "TI AR7 GPIO Support" ++ depends on AR7 ++ help ++ Give userspace access to the GPIO pins on the Texas Instruments AR7 ++ processors. ++ ++ If compiled as a module, it will be called ar7_gpio. ++ + config SCx200_GPIO + tristate "NatSemi SCx200 GPIO Support" + depends on SCx200 +--- a/drivers/char/Makefile ++++ b/drivers/char/Makefile +@@ -44,6 +44,7 @@ obj-$(CONFIG_HW_RANDOM) += hw_random/ + obj-$(CONFIG_PPDEV) += ppdev.o + obj-$(CONFIG_NWBUTTON) += nwbutton.o + obj-$(CONFIG_NWFLASH) += nwflash.o ++obj-$(CONFIG_AR7_GPIO) += ar7_gpio.o + obj-$(CONFIG_SCx200_GPIO) += scx200_gpio.o + obj-$(CONFIG_PC8736x_GPIO) += pc8736x_gpio.o + obj-$(CONFIG_NSC_GPIO) += nsc_gpio.o diff --git a/target/linux/ar7/patches-3.3/160-vlynq_try_remote_first.patch b/target/linux/ar7/patches-3.3/160-vlynq_try_remote_first.patch new file mode 100644 index 000000000..437bc89d9 --- /dev/null +++ b/target/linux/ar7/patches-3.3/160-vlynq_try_remote_first.patch @@ -0,0 +1,20 @@ +--- a/drivers/vlynq/vlynq.c ++++ b/drivers/vlynq/vlynq.c +@@ -514,9 +514,14 @@ static int __vlynq_enable_device(struct + !__vlynq_try_external(dev)) + return 0; + } else { +- if (!__vlynq_try_external(dev) || +- !__vlynq_try_local(dev) || +- !__vlynq_try_remote(dev)) ++ /* XXX: I don't really know what difference it makes, if the order ++ * of the following calls is changed, but at least in this order ++ * my fritzbox doesn't hang at startup as in ++ * https://dev.openwrt.org/ticket/7324 ++ */ ++ if (!__vlynq_try_remote(dev) || ++ !__vlynq_try_local(dev) || ++ !__vlynq_try_external(dev)) + return 0; + } + break; diff --git a/target/linux/ar7/patches-3.3/500-serial_kludge.patch b/target/linux/ar7/patches-3.3/500-serial_kludge.patch new file mode 100644 index 000000000..5c19cf22b --- /dev/null +++ b/target/linux/ar7/patches-3.3/500-serial_kludge.patch @@ -0,0 +1,28 @@ +--- a/drivers/tty/serial/8250/8250.c ++++ b/drivers/tty/serial/8250/8250.c +@@ -290,6 +290,13 @@ static const struct serial8250_config ua + .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10, + .flags = UART_CAP_FIFO | UART_CAP_AFE | UART_CAP_EFR, + }, ++ [PORT_AR7] = { ++ .name = "TI-AR7", ++ .fifo_size = 16, ++ .tx_loadsz = 16, ++ .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_00, ++ .flags = UART_CAP_FIFO | UART_CAP_AFE, ++ }, + }; + + #if defined(CONFIG_MIPS_ALCHEMY) +@@ -2798,7 +2805,11 @@ static void serial8250_console_putchar(s + struct uart_8250_port *up = + container_of(port, struct uart_8250_port, port); + ++#ifdef CONFIG_AR7 ++ wait_for_xmitr(up, BOTH_EMPTY); ++#else + wait_for_xmitr(up, UART_LSR_THRE); ++#endif + serial_out(up, UART_TX, ch); + } + diff --git a/target/linux/ar7/patches-3.3/920-ar7part.patch b/target/linux/ar7/patches-3.3/920-ar7part.patch new file mode 100644 index 000000000..9cbc53786 --- /dev/null +++ b/target/linux/ar7/patches-3.3/920-ar7part.patch @@ -0,0 +1,56 @@ +--- a/drivers/mtd/ar7part.c ++++ b/drivers/mtd/ar7part.c +@@ -29,11 +29,14 @@ + #include <linux/magic.h> + #include <linux/module.h> + ++#include <asm/mach-ar7/prom.h> ++ + #define AR7_PARTS 4 + #define ROOT_OFFSET 0xe0000 + + #define LOADER_MAGIC1 le32_to_cpu(0xfeedfa42) + #define LOADER_MAGIC2 le32_to_cpu(0xfeed1281) ++#define LOADER_MAGIC3 le32_to_cpu(0x434d4d4c) + + #ifndef SQUASHFS_MAGIC + #define SQUASHFS_MAGIC 0x73717368 +@@ -45,6 +48,10 @@ struct ar7_bin_rec { + unsigned int address; + }; + ++int create_titan_partitions(struct mtd_info *master, ++ struct mtd_partition **pparts, ++ struct mtd_part_parser_data *data); ++ + static int create_mtd_partitions(struct mtd_info *master, + struct mtd_partition **pparts, + struct mtd_part_parser_data *data) +@@ -58,6 +65,16 @@ static int create_mtd_partitions(struct + int retries = 10; + struct mtd_partition *ar7_parts; + ++ const char *prod_id ; ++ prod_id = prom_getenv("ProductID"); ++ if(prod_id && ++ (strcmp(prod_id, "CYWL")==0 || ++ strcmp(prod_id, "CYWM")==0 || ++ strcmp(prod_id, "CYLM")==0 || ++ strcmp(prod_id, "CYLL")==0)){ ++ return create_titan_partitions(master, pparts, data); ++ } ++ + ar7_parts = kzalloc(sizeof(*ar7_parts) * AR7_PARTS, GFP_KERNEL); + if (!ar7_parts) + return -ENOMEM; +--- a/drivers/mtd/titanpart.c ++++ b/drivers/mtd/titanpart.c +@@ -149,7 +149,7 @@ static void titan_add_partition(char * e + } + int create_titan_partitions(struct mtd_info *master, + struct mtd_partition **pparts, +- unsigned long origin) ++ struct mtd_part_parser_data *data) + { + struct nsp_img_hdr_head hdr; + struct nsp_img_hdr_section_info sect_info; diff --git a/target/linux/ar7/patches-3.3/950-cpmac_titan.patch b/target/linux/ar7/patches-3.3/950-cpmac_titan.patch new file mode 100644 index 000000000..a829e4e8c --- /dev/null +++ b/target/linux/ar7/patches-3.3/950-cpmac_titan.patch @@ -0,0 +1,52 @@ +--- a/drivers/net/ethernet/ti/cpmac.c ++++ b/drivers/net/ethernet/ti/cpmac.c +@@ -1159,6 +1159,8 @@ static int __devinit cpmac_probe(struct + goto fail; + } + ++ ar7_device_reset(pdata->reset_bit); ++ + dev->irq = platform_get_irq_byname(pdev, "irq"); + + dev->netdev_ops = &cpmac_netdev_ops; +@@ -1237,7 +1239,7 @@ int __devinit cpmac_init(void) + cpmac_mii->reset = cpmac_mdio_reset; + cpmac_mii->irq = mii_irqs; + +- cpmac_mii->priv = ioremap(AR7_REGS_MDIO, 256); ++ cpmac_mii->priv = ioremap(ar7_is_titan() ? TITAN_REGS_MDIO : AR7_REGS_MDIO, 256); + + if (!cpmac_mii->priv) { + printk(KERN_ERR "Can't ioremap mdio registers\n"); +@@ -1248,10 +1250,16 @@ int __devinit cpmac_init(void) + #warning FIXME: unhardcode gpio&reset bits + ar7_gpio_disable(26); + ar7_gpio_disable(27); +- ar7_device_reset(AR7_RESET_BIT_CPMAC_LO); +- ar7_device_reset(AR7_RESET_BIT_CPMAC_HI); ++ ++ if (!ar7_is_titan()) { ++ ar7_device_reset(AR7_RESET_BIT_CPMAC_LO); ++ ar7_device_reset(AR7_RESET_BIT_CPMAC_HI); ++ } + ar7_device_reset(AR7_RESET_BIT_EPHY); + ++ if (ar7_is_titan()) ++ ar7_device_reset(TITAN_RESET_BIT_EPHY1); ++ + cpmac_mii->reset(cpmac_mii); + + for (i = 0; i < 300; i++) { +@@ -1268,7 +1276,11 @@ int __devinit cpmac_init(void) + mask = 0; + } + +- cpmac_mii->phy_mask = ~(mask | 0x80000000); ++ if (ar7_is_titan()) ++ cpmac_mii->phy_mask = ~(mask | 0x80000000 | 0x40000000); ++ else ++ cpmac_mii->phy_mask = ~(mask | 0x80000000); ++ + snprintf(cpmac_mii->id, MII_BUS_ID_SIZE, "cpmac-1"); + + res = mdiobus_register(cpmac_mii); diff --git a/target/linux/ar7/patches-3.3/972-cpmac_fixup.patch b/target/linux/ar7/patches-3.3/972-cpmac_fixup.patch new file mode 100644 index 000000000..b1eb081c9 --- /dev/null +++ b/target/linux/ar7/patches-3.3/972-cpmac_fixup.patch @@ -0,0 +1,218 @@ +--- a/arch/mips/ar7/platform.c ++++ b/arch/mips/ar7/platform.c +@@ -33,7 +33,6 @@ + #include <linux/string.h> + #include <linux/etherdevice.h> + #include <linux/phy.h> +-#include <linux/phy_fixed.h> + #include <linux/gpio.h> + #include <linux/clk.h> + +@@ -248,12 +247,6 @@ static struct resource cpmac_high_res[] + }, + }; + +-static struct fixed_phy_status fixed_phy_status __initdata = { +- .link = 1, +- .speed = 100, +- .duplex = 1, +-}; +- + static struct plat_cpmac_data cpmac_low_data = { + .reset_bit = 17, + .power_bit = 20, +@@ -680,26 +673,18 @@ static int __init ar7_register_devices(v + } + + if (ar7_has_high_cpmac()) { +- res = fixed_phy_add(PHY_POLL, cpmac_high.id, &fixed_phy_status); +- if (!res) { +- cpmac_get_mac(1, cpmac_high_data.dev_addr); +- +- res = platform_device_register(&cpmac_high); +- if (res) +- pr_warning("unable to register cpmac-high: %d\n", res); +- } else +- pr_warning("unable to add cpmac-high phy: %d\n", res); +- } else +- cpmac_low_data.phy_mask = 0xffffffff; ++ cpmac_get_mac(1, cpmac_high_data.dev_addr); + +- res = fixed_phy_add(PHY_POLL, cpmac_low.id, &fixed_phy_status); +- if (!res) { +- cpmac_get_mac(0, cpmac_low_data.dev_addr); +- res = platform_device_register(&cpmac_low); ++ res = platform_device_register(&cpmac_high); + if (res) +- pr_warning("unable to register cpmac-low: %d\n", res); ++ pr_warning("unable to register cpmac-high: %d\n", res); + } else +- pr_warning("unable to add cpmac-low phy: %d\n", res); ++ cpmac_low_data.phy_mask = 0xffffffff; ++ ++ cpmac_get_mac(0, cpmac_low_data.dev_addr); ++ res = platform_device_register(&cpmac_low); ++ if (res) ++ pr_warning("unable to register cpmac-low: %d\n", res); + + detect_leds(); + res = platform_device_register(&ar7_gpio_leds); +@@ -712,8 +697,10 @@ static int __init ar7_register_devices(v + + /* Register watchdog only if enabled in hardware */ + bootcr = ioremap_nocache(AR7_REGS_DCL, 4); +- val = readl(bootcr); +- iounmap(bootcr); ++ if (bootcr) { ++ val = readl(bootcr); ++ iounmap(bootcr); ++ } + if (val & AR7_WDT_HW_ENA) { + if (ar7_has_high_vlynq()) + ar7_wdt_res.start = UR8_REGS_WDT; +--- a/arch/mips/include/asm/mach-ar7/ar7.h ++++ b/arch/mips/include/asm/mach-ar7/ar7.h +@@ -42,6 +42,7 @@ + #define AR7_REGS_PINSEL (AR7_REGS_BASE + 0x160C) + #define AR7_REGS_VLYNQ0 (AR7_REGS_BASE + 0x1800) + #define AR7_REGS_DCL (AR7_REGS_BASE + 0x1a00) ++#define AR7_REGS_MII (AR7_REGS_BASE + 0x1a08) + #define AR7_REGS_VLYNQ1 (AR7_REGS_BASE + 0x1c00) + #define AR7_REGS_MDIO (AR7_REGS_BASE + 0x1e00) + #define AR7_REGS_IRQ (AR7_REGS_BASE + 0x2400) +--- a/drivers/net/ethernet/ti/cpmac.c ++++ b/drivers/net/ethernet/ti/cpmac.c +@@ -35,7 +35,6 @@ + #include <linux/skbuff.h> + #include <linux/mii.h> + #include <linux/phy.h> +-#include <linux/phy_fixed.h> + #include <linux/platform_device.h> + #include <linux/dma-mapping.h> + #include <linux/clk.h> +@@ -48,14 +47,11 @@ MODULE_LICENSE("GPL"); + MODULE_ALIAS("platform:cpmac"); + + static int debug_level = 8; +-static int dumb_switch; + +-/* Next 2 are only used in cpmac_probe, so it's pointless to change them */ ++/* Next is only used in cpmac_probe, so it's pointless to change them */ + module_param(debug_level, int, 0444); +-module_param(dumb_switch, int, 0444); + + MODULE_PARM_DESC(debug_level, "Number of NETIF_MSG bits to enable"); +-MODULE_PARM_DESC(dumb_switch, "Assume switch is not connected to MDIO bus"); + + #define CPMAC_VERSION "0.5.2" + /* frame size + 802.1q tag + FCS size */ +@@ -674,9 +670,8 @@ static void cpmac_hw_start(struct net_de + for (i = 0; i < 8; i++) + cpmac_write(priv->regs, CPMAC_MAC_ADDR_LO(i), dev->dev_addr[5]); + cpmac_write(priv->regs, CPMAC_MAC_ADDR_MID, dev->dev_addr[4]); +- cpmac_write(priv->regs, CPMAC_MAC_ADDR_HI, dev->dev_addr[0] | +- (dev->dev_addr[1] << 8) | (dev->dev_addr[2] << 16) | +- (dev->dev_addr[3] << 24)); ++ cpmac_write(priv->regs, CPMAC_MAC_ADDR_HI, be32_to_cpu(*(u32 *) ++ dev->dev_addr)); + cpmac_write(priv->regs, CPMAC_MAX_LENGTH, CPMAC_SKB_SIZE); + cpmac_write(priv->regs, CPMAC_UNICAST_CLEAR, 0xff); + cpmac_write(priv->regs, CPMAC_RX_INT_CLEAR, 0xff); +@@ -1108,8 +1103,6 @@ static const struct net_device_ops cpmac + .ndo_set_mac_address = eth_mac_addr, + }; + +-static int external_switch; +- + static int __devinit cpmac_probe(struct platform_device *pdev) + { + int rc, phy_id; +@@ -1121,25 +1114,18 @@ static int __devinit cpmac_probe(struct + + pdata = pdev->dev.platform_data; + +- if (external_switch || dumb_switch) { +- strncpy(mdio_bus_id, "fixed-0", MII_BUS_ID_SIZE); /* fixed phys bus */ +- phy_id = pdev->id; +- } else { +- for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) { +- if (!(pdata->phy_mask & (1 << phy_id))) +- continue; +- if (!cpmac_mii->phy_map[phy_id]) +- continue; +- strncpy(mdio_bus_id, cpmac_mii->id, MII_BUS_ID_SIZE); +- break; +- } ++ for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) { ++ if (!(pdata->phy_mask & (1 << phy_id))) ++ continue; ++ if (!cpmac_mii->phy_map[phy_id]) ++ continue; ++ strncpy(mdio_bus_id, cpmac_mii->id, MII_BUS_ID_SIZE); ++ break; + } + + if (phy_id == PHY_MAX_ADDR) { +- dev_err(&pdev->dev, "no PHY present, falling back " +- "to switch on MDIO bus 0\n"); +- strncpy(mdio_bus_id, "fixed-0", MII_BUS_ID_SIZE); /* fixed phys bus */ +- phy_id = pdev->id; ++ printk(KERN_ERR "cpmac: No PHY present\n"); ++ return -ENXIO; + } + + dev = alloc_etherdev_mq(sizeof(*priv), CPMAC_QUEUES); +@@ -1228,6 +1214,7 @@ int __devinit cpmac_init(void) + { + u32 mask; + int i, res; ++ void __iomem *mii_reg; + + cpmac_mii = mdiobus_alloc(); + if (cpmac_mii == NULL) +@@ -1251,14 +1238,14 @@ int __devinit cpmac_init(void) + ar7_gpio_disable(26); + ar7_gpio_disable(27); + +- if (!ar7_is_titan()) { ++ if (ar7_is_titan()) { ++ ar7_device_reset(AR7_RESET_BIT_EPHY); ++ ar7_device_reset(TITAN_RESET_BIT_EPHY1); ++ } else { ++ ar7_device_reset(AR7_RESET_BIT_EPHY); + ar7_device_reset(AR7_RESET_BIT_CPMAC_LO); + ar7_device_reset(AR7_RESET_BIT_CPMAC_HI); + } +- ar7_device_reset(AR7_RESET_BIT_EPHY); +- +- if (ar7_is_titan()) +- ar7_device_reset(TITAN_RESET_BIT_EPHY1); + + cpmac_mii->reset(cpmac_mii); + +@@ -1270,10 +1257,22 @@ int __devinit cpmac_init(void) + msleep(10); + } + +- mask &= 0x7fffffff; ++ mask &= ar7_is_titan()? ~(0x80000000 | 0x40000000) : ~(0x80000000); + if (mask & (mask - 1)) { +- external_switch = 1; +- mask = 0; ++ if (!ar7_has_high_cpmac()) { ++ if (ar7_is_titan()) { ++ ar7_device_disable(AR7_RESET_BIT_EPHY); ++ ar7_device_disable(TITAN_RESET_BIT_EPHY1); ++ } else ++ ar7_device_disable(AR7_RESET_BIT_EPHY); ++ ++ //Titan remap might be different ++ mii_reg = ioremap(AR7_REGS_MII, 4); ++ if (mii_reg) { ++ writel(readl(mii_reg) | 1, mii_reg); ++ iounmap(mii_reg); ++ } ++ } + } + + if (ar7_is_titan()) diff --git a/target/linux/ar7/profiles/100-Annex-A.mk b/target/linux/ar7/profiles/100-Annex-A.mk new file mode 100644 index 000000000..3d74b5d7d --- /dev/null +++ b/target/linux/ar7/profiles/100-Annex-A.mk @@ -0,0 +1,17 @@ +# +# Copyright (C) 2009 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +define Profile/Annex-A + NAME:=Annex-A DSL firmware (default) + PACKAGES:=kmod-sangam-atm-annex-a +endef + +define Profile/Annex-A/Description + Package set compatible with Annex-A DSL lines (most countries). +endef +$(eval $(call Profile,Annex-A)) + diff --git a/target/linux/ar7/profiles/110-Annex-B.mk b/target/linux/ar7/profiles/110-Annex-B.mk new file mode 100644 index 000000000..66692e796 --- /dev/null +++ b/target/linux/ar7/profiles/110-Annex-B.mk @@ -0,0 +1,17 @@ +# +# Copyright (C) 2009 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +define Profile/Annex-B + NAME:=Annex-B DSL firmware + PACKAGES:=kmod-sangam-atm-annex-b +endef + +define Profile/Annex-B/Description + Package set compatible with Annex-B DSL lines (Germany). +endef +$(eval $(call Profile,Annex-B)) + diff --git a/target/linux/ar7/profiles/200-Texas.mk b/target/linux/ar7/profiles/200-Texas.mk new file mode 100644 index 000000000..7d868bdb0 --- /dev/null +++ b/target/linux/ar7/profiles/200-Texas.mk @@ -0,0 +1,18 @@ +# +# Copyright (C) 2006-2009 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +define Profile/Texas + NAME:=Texas Instruments WiFi (mac80211) + PACKAGES:=kmod-acx-mac80211 +endef + +define Profile/Texas/Description + Package set compatible with hardware using Texas Instruments WiFi cards + using the mac80211 driver. +endef +$(eval $(call Profile,Texas)) + diff --git a/target/linux/ar7/profiles/210-None.mk b/target/linux/ar7/profiles/210-None.mk new file mode 100644 index 000000000..2fcfacde9 --- /dev/null +++ b/target/linux/ar7/profiles/210-None.mk @@ -0,0 +1,17 @@ +# +# Copyright (C) 2006 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +define Profile/None + NAME:=No WiFi + PACKAGES:= +endef + +define Profile/None/Description + Package set without WiFi support +endef +$(eval $(call Profile,None)) + diff --git a/target/linux/ar7/src/adam2patcher.c b/target/linux/ar7/src/adam2patcher.c new file mode 100644 index 000000000..25a78074a --- /dev/null +++ b/target/linux/ar7/src/adam2patcher.c @@ -0,0 +1,59 @@ +/* + * patcher.c - ADAM2 patcher for Netgear DG834 (and compatible) + * + * Copyright (C) 2006 Felix Fietkau + * + * 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. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <stddef.h> +#include <unistd.h> +#include <fcntl.h> +#include <stdint.h> +#include <sys/mman.h> +#include <sys/stat.h> +#include <string.h> + +#include <sys/ioctl.h> + +int main(int argc, char **argv) +{ + int fd; + char *ptr; + uint32_t *i; + + if (argc != 2) { + fprintf(stderr, "Usage: %s <filename>\n", argv[0]); + exit(1); + } + + if (((fd = open(argv[1], O_RDWR)) < 0) + || ((ptr = mmap(0, 128 * 1024, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == (void *) (-1))) { + fprintf(stderr, "Can't open file\n"); + exit(1); + } + + i = (uint32_t *) &ptr[0x3944]; + if (*i == 0x0c000944) { + fprintf(stderr, "Unpatched ADAM2 detected. Patching... "); + *i = 0x00000000; + msync(i, sizeof(*i), MS_SYNC|MS_INVALIDATE); + fprintf(stderr, "done!\n"); + } else if (*i == 0x00000000) { + fprintf(stderr, "Patched ADAM2 detected.\n"); + } else { + fprintf(stderr, "Unknown ADAM2 detected. Can't patch!\n"); + } + + close(fd); +} |