packages: clean up the package folder

Signed-off-by: John Crispin <blogic@openwrt.org>

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@37007 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
John Crispin
2013-06-21 16:54:37 +00:00
parent d2642de749
commit f1b4824c86
603 changed files with 28 additions and 28 deletions

View File

@@ -1,22 +0,0 @@
menu "Configuration"
depends on (PACKAGE_kmod-sangam-atm-annex-a || PACKAGE_kmod-sangam-atm-annex-b)
choice
prompt "Firmware version"
default AR7_ATM_FW_VERSION_704
help
This option allows you to switch between firmware/driver versions which
might improve the DSL line speed.
config AR7_ATM_FW_VERSION_705
bool "D7.05.01.00"
config AR7_ATM_FW_VERSION_704
bool "D7.04.03.00"
config AR7_ATM_FW_VERSION_703
bool "D7.03.01.00"
endchoice
endmenu

View File

@@ -1,100 +0,0 @@
#
# Copyright (C) 2006-2009 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)/kernel.mk
PKG_NAME:=sangam_atm
ifeq ($(CONFIG_AR7_ATM_FW_VERSION_705),y)
PKG_VERSION:=D7.05.01.00
PKG_MD5SUM:=42ee465be5cfbe9476fc25deb260d450
PKG_RELEASE:=R1
PATCH_DIR:=patches-$(PKG_VERSION)
endif
ifeq ($(CONFIG_AR7_ATM_FW_VERSION_704),y)
PKG_VERSION:=D7.04.03.00
PKG_MD5SUM:=3d76004e46f09e88931f91670cb420ad
PKG_RELEASE:=R1
PATCH_DIR:=patches-$(PKG_VERSION)
endif
ifeq ($(CONFIG_AR7_ATM_FW_VERSION_703),y)
PKG_VERSION:=D7.03.01.00
PKG_MD5SUM:=bc6e9c6adb1be25820c7ee661de8ca7d
PKG_RELEASE:=R2
PATCH_DIR:=patches-D7.04.03.00
endif
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE).tar.bz2
PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
include $(INCLUDE_DIR)/package.mk
define KernelPackage/sangam-atm/Default
SUBMENU:=Network Devices
DEPENDS:=@TARGET_ar7_generic +kmod-atm
TITLE:=AR7 ADSL driver
FILES:=$(PKG_BUILD_DIR)/tiatm.ko
AUTOLOAD:=$(call AutoLoad,50,tiatm)
MAINTAINER:=Florian Fainelli <florian@openwrt.org>
MENU:=1
endef
define KernelPackage/sangam-atm/config
source "$(SOURCE)/Config.in"
endef
define KernelPackage/sangam-atm-annex-a
$(call KernelPackage/sangam-atm/Default)
TITLE+= (Annex A, ADSL over POTS)
endef
define KernelPackage/sangam-atm-annex-a/description
The AR7 ADSL driver for Annex A (ADSL over POTS).
endef
define KernelPackage/sangam-atm-annex-a/config
$(call KernelPackage/sangam-atm/config)
endef
define KernelPackage/sangam-atm-annex-b
$(call KernelPackage/sangam-atm/Default)
TITLE+= (Annex B, ADSL over ISDN)
endef
define KernelPackage/sangam-atm-annex-b/description
The AR7 ADSL driver for Annex B (ADSL over ISDN).
endef
define KernelPackage/sangam-atm-annex-a/config
$(call KernelPackage/sangam-atm/config)
endef
define Build/Compile
$(MAKE) -C "$(LINUX_DIR)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
ARCH="$(LINUX_KARCH)" \
SUBDIRS="$(PKG_BUILD_DIR)" \
modules
endef
define KernelPackage/sangam-atm-annex-a/install
mkdir -p $(1)/lib/firmware
$(INSTALL_DATA) $(PKG_BUILD_DIR)/ar0700mp.bin $(1)/lib/firmware/
ln -sf ar0700mp.bin $(1)/lib/firmware/ar0700xx.bin
endef
define KernelPackage/sangam-atm-annex-b/install
mkdir -p $(1)/lib/firmware
$(INSTALL_DATA) $(PKG_BUILD_DIR)/ar0700db.bin $(1)/lib/firmware/
ln -sf ar0700db.bin $(1)/lib/firmware/ar0700xx.bin
endef
$(eval $(call KernelPackage,sangam-atm-annex-a))
$(eval $(call KernelPackage,sangam-atm-annex-b))

View File

@@ -1,768 +0,0 @@
--- a/cppi_cpaal5.c
+++ b/cppi_cpaal5.c
@@ -352,7 +352,7 @@ static int halRxReturn(HAL_RECEIVEINFO *
{
/* malloc failed, add this RCB to Needs Buffer List */
TempRcb->FragCount = 1; /*MJH+030417*/
- (HAL_RCB *)TempRcb->Eop = TempRcb; /* GSG +030430 */
+ TempRcb->Eop = TempRcb; /* GSG +030430 */
if(HalDev->NeedsCount < MAX_NEEDS) /* +MJH 030410 */
{ /* +MJH 030410 */
--- a/dsl_hal_api.c
+++ b/dsl_hal_api.c
@@ -254,15 +254,15 @@
* of phyEnableDisableWord & phyControlWord to avoid changing API struct
* which may cause change required to application data structure.
******************************************************************************/
-#include <dev_host_interface.h>
-#include <dsl_hal_register.h>
-#include <dsl_hal_support.h>
+#include "dev_host_interface.h"
+#include "dsl_hal_register.h"
+#include "dsl_hal_support.h"
#ifndef NO_ADV_STATS
-#include <dsl_hal_logtable.h>
+#include "dsl_hal_logtable.h"
#endif
-#include <dsl_hal_version.h>
+#include "dsl_hal_version.h"
// UR8_MERGE_START CQ11054 Jack Zhang
static unsigned int highprecision_selected = 0; //By default we use low precision for backward compt.
--- a/dsl_hal_support.c
+++ b/dsl_hal_support.c
@@ -140,9 +140,9 @@
* oamFeature are overriden
// UR8_MERGE_END CQ10774 Ram
*******************************************************************************/
-#include <dev_host_interface.h>
-#include <dsl_hal_register.h>
-#include <dsl_hal_support.h>
+#include "dev_host_interface.h"
+#include "dsl_hal_register.h"
+#include "dsl_hal_support.h"
#define NUM_READ_RETRIES 3
static unsigned int dslhal_support_adsl2ByteSwap32(unsigned int in32Bits);
--- a/dsl_hal_support.h
+++ b/dsl_hal_support.h
@@ -49,7 +49,7 @@
* 04Nov05 0.11.00 CPH Fixed T1413 mode got Zero DS/US rate when DSL_BIT_TMODE is set.
*******************************************************************************/
-#include <dsl_hal_api.h>
+#include "dsl_hal_api.h"
#define virtual2Physical(a) (((int)a)&~0xe0000000)
/* External Function Prototype Declarations */
--- a/Makefile
+++ b/Makefile
@@ -1,18 +1,9 @@
-# File: drivers/atm/ti_evm3/Makefile
#
-# Makefile for the Texas Instruments EVM3 ADSL/ATM driver.
+# Makefile for the TIATM device driver.
#
-#
-# Copyright (c) 2000 Texas Instruments Incorporated.
-# Jeff Harrell (jharrell@telogy.com)
-# Viren Balar (vbalar@ti.com)
-# Victor Wells (vwells@telogy.com)
-#
-include $(TOPDIR)/Rules.make
-
-
-
-
-
-
+CONFIG_SANGAM_ATM=m
+#EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
+EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
+obj-$(CONFIG_SANGAM_ATM) := tiatm.o
+tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o
--- a/tn7atm.c
+++ b/tn7atm.c
@@ -61,7 +61,6 @@
* UR8_MERGE_END CQ11057*
*********************************************************************************************/
-#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
@@ -69,11 +68,14 @@
#include <linux/delay.h>
#include <linux/spinlock.h>
#include <linux/smp_lock.h>
-#include <asm/io.h>
-#include <asm/mips-boards/prom.h>
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <linux/ctype.h>
+
+#include <asm/io.h>
+#include <asm/ar7/ar7.h>
+#include <asm/ar7/prom.h>
+
#include "dsl_hal_api.h"
#include "tn7atm.h"
#include "tn7api.h"
@@ -82,6 +84,7 @@
#include "dsl_hal_register.h"
#ifdef MODULE
+MODULE_LICENSE("GPL");
MODULE_DESCRIPTION ("Tnetd73xx ATM Device Driver");
MODULE_AUTHOR ("Zhicheng Tang");
#endif
@@ -100,9 +103,9 @@ MODULE_AUTHOR ("Zhicheng Tang");
/*end of externs */
-#ifndef TI_STATIC_ALLOCATIONS
-#define TI_STATIC_ALLOCATIONS
-#endif
+//#ifndef TI_STATIC_ALLOCATIONS
+//#define TI_STATIC_ALLOCATIONS
+//#endif
#define tn7atm_kfree_skb(x) dev_kfree_skb(x)
@@ -114,7 +117,7 @@ static int EnableQoS = FALSE;
/* prototypes */
static int tn7atm_set_can_support_adsl2 (int can);
-static int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci);
+static int tn7atm_open (struct atm_vcc *vcc);
static void tn7atm_close (struct atm_vcc *vcc);
@@ -257,13 +260,12 @@ static const struct atmdev_ops tn7atm_op
getsockopt: NULL,
setsockopt: NULL,
send: tn7atm_send,
- sg_send: NULL,
phy_put: NULL,
phy_get: NULL,
change_qos: tn7atm_change_qos,
};
-const char drv_proc_root_folder[] = "avalanche/";
+const char drv_proc_root_folder[] = "avalanche";
static struct proc_dir_entry *root_proc_dir_entry = NULL;
#define DRV_PROC_MODE 0644
static int proc_root_already_exists = TRUE;
@@ -559,56 +561,6 @@ static int turbodsl_check_priority_type(
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
- * Function: int tn7atm_walk_vccs(struct atm_dev *dev, short *vcc, int *vci)
- *
- * Description: retrieve VPI/VCI for connection
- *
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-static int tn7atm_walk_vccs (struct atm_vcc *vcc, short *vpi, int *vci)
-{
- struct atm_vcc *walk;
-
- /*
- * find a free VPI
- */
- if (*vpi == ATM_VPI_ANY)
- {
-
- for (*vpi = 0, walk = vcc->dev->vccs; walk; walk = walk->next)
- {
-
- if ((walk->vci == *vci) && (walk->vpi == *vpi))
- {
- (*vpi)++;
- walk = vcc->dev->vccs;
- }
- }
- }
-
- /*
- * find a free VCI
- */
- if (*vci == ATM_VCI_ANY)
- {
-
- for (*vci = ATM_NOT_RSV_VCI, walk = vcc->dev->vccs; walk;
- walk = walk->next)
- {
-
- if ((walk->vpi = *vpi) && (walk->vci == *vci))
- {
- *vci = walk->vci + 1;
- walk = vcc->dev->vccs;
- }
- }
- }
-
- return 0;
-}
-
-
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *
* Function: int tn7atm_sar_irq(void)
*
* Description: tnetd73xx SAR interrupt.
@@ -693,7 +645,7 @@ static int __init tn7atm_irq_request (st
* Register SAR interrupt
*/
priv->sar_irq = LNXINTNUM (ATM_SAR_INT); /* Interrupt line # */
- if (request_irq (priv->sar_irq, tn7atm_sar_irq, SA_INTERRUPT, "SAR ", dev))
+ if (request_irq (priv->sar_irq, tn7atm_sar_irq, IRQF_DISABLED, "SAR ", dev))
printk ("Could not register tn7atm_sar_irq\n");
/*
@@ -704,14 +656,14 @@ static int __init tn7atm_irq_request (st
{
def_sar_inter_pace = os_atoi (ptr);
}
- avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
- def_sar_inter_pace);
+/* avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
+ def_sar_inter_pace);*/
/*
* Reigster Receive interrupt A
*/
priv->dsl_irq = LNXINTNUM (ATM_DSL_INT); /* Interrupt line # */
- if (request_irq (priv->dsl_irq, tn7atm_dsl_irq, SA_INTERRUPT, "DSL ", dev))
+ if (request_irq (priv->dsl_irq, tn7atm_dsl_irq, IRQF_DISABLED, "DSL ", dev))
printk ("Could not register tn7atm_dsl_irq\n");
/***** VRB Tasklet Mode ****/
@@ -875,11 +827,15 @@ static int __init tn7atm_get_ESI (struct
#define ATM_VBR_RT 5
#endif
-int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci)
+int tn7atm_open (struct atm_vcc *vcc)
{
tn7atm_activate_vc_parm_t tn7atm_activate_vc_parm;
int rc;
//int flags;
+ tn7atm_activate_vc_parm.pcr = 0x20000;
+ tn7atm_activate_vc_parm.scr = 0x20000;
+ tn7atm_activate_vc_parm.mbs = 0x20000;
+ tn7atm_activate_vc_parm.cdvt = 10000;
dgprintf(1, "tn7atm_open()\n");
@@ -891,24 +847,18 @@ int tn7atm_open (struct atm_vcc *vcc, sh
return -1;
}
- MOD_INC_USE_COUNT;
+// MOD_INC_USE_COUNT;
- /* find a free VPI/VCI */
- tn7atm_walk_vccs(vcc, &vpi, &vci);
-
- vcc->vpi = vpi;
- vcc->vci = vci;
-
- if ((vci == ATM_VCI_UNSPEC) || (vpi == ATM_VCI_UNSPEC))
+ if ((vcc->vci == ATM_VCI_UNSPEC) || (vcc->vpi == ATM_VCI_UNSPEC))
{
- MOD_DEC_USE_COUNT;
+// MOD_DEC_USE_COUNT;
return -EBUSY;
}
- tn7atm_activate_vc_parm.vpi = vpi;
- tn7atm_activate_vc_parm.vci = vci;
+ tn7atm_activate_vc_parm.vpi = vcc->vpi;
+ tn7atm_activate_vc_parm.vci = vcc->vci;
- if ((vpi == CLEAR_EOC_VPI) && (vci == CLEAR_EOC_VCI))
+ if ((vcc->vpi == CLEAR_EOC_VPI) && (vcc->vci == CLEAR_EOC_VCI))
{
/* always use (max_dma_chan+1) for clear eoc */
tn7atm_activate_vc_parm.chan = EOC_DMA_CHAN;
@@ -916,7 +866,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
/* check to see whether clear eoc is opened or not */
if (tn7atm_activate_vc_parm.priv->lut[tn7atm_activate_vc_parm.chan].inuse)
{
- MOD_DEC_USE_COUNT;
+// MOD_DEC_USE_COUNT;
printk("tn7atm_open: Clear EOC channel (dmachan=%d) already in use.\n", tn7atm_activate_vc_parm.chan);
return -EBUSY;
}
@@ -925,7 +875,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
if (rc)
{
printk("tn7atm_open: failed to setup clear_eoc\n");
- MOD_DEC_USE_COUNT;
+// MOD_DEC_USE_COUNT;
return -EBUSY;
}
tn7atm_set_lut(tn7atm_activate_vc_parm.priv,vcc, tn7atm_activate_vc_parm.chan);
@@ -934,17 +884,17 @@ int tn7atm_open (struct atm_vcc *vcc, sh
}
else /* PVC channel setup */
{
- if ((vpi==REMOTE_MGMT_VPI) && (vci==REMOTE_MGMT_VCI))
+ if ((vcc->vpi==REMOTE_MGMT_VPI) && (vcc->vci==REMOTE_MGMT_VCI))
{
tn7atm_activate_vc_parm.chan = 14; /* always use chan 14 for MII PVC-base romote mgmt */
}
else
{
- rc = tn7atm_lut_find(vpi, vci);
+ rc = tn7atm_lut_find(vcc->vpi, vcc->vci);
/* check to see whether PVC is opened or not */
if(ATM_NO_DMA_CHAN != rc)
{
- MOD_DEC_USE_COUNT;
+// MOD_DEC_USE_COUNT;
printk("PVC already opened. dmachan = %d\n", rc);
return -EBUSY;
}
@@ -976,6 +926,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
tn7atm_activate_vc_parm.priority = 2;
break;
+#if 0
case ATM_VBR: /* Variable Bit Rate-Non RealTime*/
tn7atm_activate_vc_parm.qos = 1;
tn7atm_activate_vc_parm.priority = 1;
@@ -997,6 +948,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
tn7atm_activate_vc_parm.mbs = vcc->qos.txtp.max_pcr;
tn7atm_activate_vc_parm.cdvt = vcc->qos.txtp.max_cdv;
break;
+#endif
default:
tn7atm_activate_vc_parm.qos = 2;
@@ -1024,7 +976,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
if (rc < 0)
{
printk("failed to activate hw channel\n");
- MOD_DEC_USE_COUNT;
+// MOD_DEC_USE_COUNT;
tn7atm_lut_clear(vcc, tn7atm_activate_vc_parm.chan);
//spin_unlock_irqrestore(&chan_init_lock, flags);
return -EBUSY;
@@ -1114,7 +1066,7 @@ void tn7atm_close (struct atm_vcc *vcc)
tn7atm_lut_clear (vcc, dmachan);
//spin_unlock_irqrestore (&closeLock, closeFlag);
- MOD_DEC_USE_COUNT;
+// MOD_DEC_USE_COUNT;
dgprintf (1, "Leave tn7atm_close\n");
}
@@ -1528,8 +1480,7 @@ int tn7atm_receive (void *os_dev, int ch
* firewall is on */
dgprintf (3, "pushing the skb...\n");
-
- skb->stamp = vcc->timestamp = xtime;
+ __net_timestamp(skb);
xdump ((unsigned char *) skb->data, skb->len, 5);
@@ -1725,8 +1676,7 @@ static void tn7atm_exit (void)
kfree (dev->dev_data);
- // atm_dev_deregister (dev);
- shutdown_atm_dev (dev);
+ atm_dev_deregister (dev);
/*
* remove proc entries
@@ -1885,9 +1835,6 @@ static int __init tn7atm_detect (void)
/*
* Set up proc entry for atm stats
*/
- if (tn7atm_xlate_proc_name
- (drv_proc_root_folder, &root_proc_dir_entry, &residual))
- {
printk ("Creating new root folder %s in the proc for the driver stats \n",
drv_proc_root_folder);
root_proc_dir_entry = proc_mkdir (drv_proc_root_folder, NULL);
@@ -1897,7 +1844,6 @@ static int __init tn7atm_detect (void)
return -ENOMEM;
}
proc_root_already_exists = FALSE;
- }
/*
* AV: Clean-up. Moved all the definitions to the data structure.
@@ -2479,7 +2425,5 @@ static int tn7atm_proc_qos_write(struct
return count;
}
-#ifdef MODULE
module_init (tn7atm_detect);
module_exit (tn7atm_exit);
-#endif /* MODULE */
--- a/tn7atm.h
+++ b/tn7atm.h
@@ -19,7 +19,8 @@
//#include "mips_support.h"
#include <linux/list.h>
-#include <linux/config.h>
+#define MIPS_EXCEPTION_OFFSET 8
+#define LNXINTNUM(x)((x) + MIPS_EXCEPTION_OFFSET)
#ifdef CONFIG_MODVERSIONS
#include <linux/modversions.h>
--- a/tn7dsl.c
+++ b/tn7dsl.c
@@ -94,7 +94,6 @@
* 1/02/07 JZ CQ11054: Data Precision and Range Changes for TR-069 Conformance
* UR8_MERGE_END CQ11054*
*********************************************************************************************/
-#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
@@ -102,8 +101,6 @@
#include <linux/delay.h>
#include <linux/spinlock.h>
#include <linux/smp_lock.h>
-#include <asm/io.h>
-#include <asm/mips-boards/prom.h>
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <linux/ctype.h>
@@ -111,6 +108,12 @@
#include <linux/timer.h>
#include <linux/vmalloc.h>
#include <linux/file.h>
+#include <linux/firmware.h>
+
+#include <asm/io.h>
+#include <asm/ar7/ar7.h>
+#include <asm/ar7/prom.h>
+
/* Modules specific header files */
#include "tn7atm.h"
#include "tn7api.h"
@@ -173,7 +176,7 @@ led_reg_t ledreg[2];
static struct led_funcs ledreg[2];
#endif
-#define DEV_DSLMOD 1
+#define DEV_DSLMOD CTL_UNNUMBERED
#define MAX_STR_SIZE 256
#define DSL_MOD_SIZE 256
@@ -299,7 +302,7 @@ static PITIDSLHW_T pIhw;
static volatile int bshutdown;
static char info[MAX_STR_SIZE];
/* Used for DSL Polling enable */
-static DECLARE_MUTEX_LOCKED (adsl_sem_overlay);
+static struct semaphore adsl_sem_overlay;
//kthread_t overlay_thread;
/* end of module wide declars */
@@ -323,6 +326,14 @@ static int tn7dsl_proc_snr_print (char *
#define gDot1(a) ((a>0)?(a%10):((-a)%10))
// UR8_MERGE_END CQ11054*
+int avalanche_request_intr_pacing(int irq_nr, unsigned int blk_num,
+ unsigned int pace_value)
+{
+ printk("avalanche_request_pacing(%d, %u, %u); // not implemented\n", irq_nr, blk_num, pace_value);
+ return 0;
+}
+
+
int os_atoi(const char *pStr)
{
int MulNeg = (*pStr == '-' ? -1 : 1);
@@ -359,39 +370,6 @@ void dprintf (int uDbgLevel, char *szFmt
#endif
}
-int strcmp(const char *s1, const char *s2)
-{
-
- int size = strlen(s1);
-
- return(strncmp(s1, s2, size));
-}
-
-int strncmp(const char *s1, const char *s2, size_t size)
-{
- int i = 0;
- int max_size = (int)size;
-
- while((s1[i] != 0) && i < max_size)
- {
- if(s2[i] == 0)
- {
- return -1;
- }
- if(s1[i] != s2[i])
- {
- return 1;
- }
- i++;
- }
- if(s2[i] != 0)
- {
- return 1;
- }
-
- return 0;
-}
-
// * UR8_MERGE_START CQ10640 Jack Zhang
int tn7dsl_dump_dsp_memory(char *input_str) //cph99
{
@@ -441,101 +419,74 @@ unsigned int shim_osGetCpuFrequency(void
return CpuFrequency;
}
-int shim_osLoadFWImage(unsigned char *ptr)
+static void avsar_release(struct device *dev)
{
- unsigned int bytesRead;
- mm_segment_t oldfs;
- static struct file *filp;
- unsigned int imageLength=0x5ffff;
-
-
- dgprintf(4, "tn7dsl_read_dsp()\n");
-
- dgprintf(4,"open file %s\n", DSP_FIRMWARE_PATH);
-
- filp=filp_open(DSP_FIRMWARE_PATH,00,O_RDONLY);
- if(filp ==NULL)
- {
- printk("Failed: Could not open DSP binary file\n");
- return -1;
- }
-
- if (filp->f_dentry != NULL)
- {
- if (filp->f_dentry->d_inode != NULL)
- {
- printk ("DSP binary filesize = %d bytes\n",
- (int) filp->f_dentry->d_inode->i_size);
- imageLength = (unsigned int)filp->f_dentry->d_inode->i_size + 0x200;
- }
- }
-
- if (filp->f_op->read==NULL)
- return -1; /* File(system) doesn't allow reads */
-
- /*
- * Disable parameter checking
- */
- oldfs = get_fs();
- set_fs(KERNEL_DS);
-
- /*
- * Now read bytes from postion "StartPos"
- */
- filp->f_pos = 0;
-
- bytesRead = filp->f_op->read(filp,ptr,imageLength,&filp->f_pos);
-
- dgprintf(4,"file length = %d\n", bytesRead);
-
- set_fs(oldfs);
-
- /*
- * Close the file
- */
- fput(filp);
-
- return bytesRead;
+ printk(KERN_DEBUG "avsar firmware released\n");
}
+static struct device avsar = {
+ .bus_id = "vlynq",
+ .release = avsar_release,
+};
-unsigned int shim_read_overlay_page (void *ptr, unsigned int secOffset,
- unsigned int secLength)
+int shim_osLoadFWImage(unsigned char *ptr)
{
- unsigned int bytesRead;
- mm_segment_t oldfs;
- struct file *filp;
-
- dgprintf(4,"shim_read_overlay_page\n");
- //dgprintf(4,"sec offset=%d, sec length =%d\n", secOffset, secLength);
+ const struct firmware *fw_entry;
+ size_t size;
- filp=filp_open(DSP_FIRMWARE_PATH,00,O_RDONLY);
- if(filp ==NULL)
- {
- printk("Failed: Could not open DSP binary file\n");
- return -1;
- }
-
- if (filp->f_op->read==NULL)
- return -1; /* File(system) doesn't allow reads */
-
- /*
- * Now read bytes from postion "StartPos"
- */
-
- if(filp->f_op->llseek)
- filp->f_op->llseek(filp,secOffset, 0);
- oldfs = get_fs();
- set_fs(KERNEL_DS);
- filp->f_pos = secOffset;
- bytesRead = filp->f_op->read(filp,ptr,secLength,&filp->f_pos);
-
- set_fs(oldfs);
- /*
- * Close the file
- */
- fput(filp);
- return bytesRead;
+ printk("requesting firmware image \"ar0700xx.bin\"\n");
+ if(device_register(&avsar) < 0) {
+ printk(KERN_ERR
+ "avsar: device_register fails\n");
+ return -1;
+ }
+
+ if(request_firmware(&fw_entry, "ar0700xx.bin", &avsar)) {
+ printk(KERN_ERR
+ "avsar: Firmware not available\n");
+ device_unregister(&avsar);
+ return -1;
+ }
+ size = fw_entry->size;
+ device_unregister(&avsar);
+ if(size > 0x5ffff) {
+ printk(KERN_ERR
+ "avsar: Firmware too big (%d bytes)\n", size);
+ release_firmware(fw_entry);
+ return -1;
+ }
+ memcpy(ptr, fw_entry->data, size);
+ release_firmware(fw_entry);
+ return size;
+}
+
+unsigned int shim_read_overlay_page(void *ptr, unsigned int secOffset, unsigned int secLength)
+{
+ const struct firmware *fw_entry;
+
+ printk("requesting firmware image \"ar0700xx.bin\"\n");
+ if(device_register(&avsar) < 0) {
+ printk(KERN_ERR
+ "avsar: device_register fails\n");
+ return -1;
+ }
+
+ if(request_firmware(&fw_entry, "ar0700xx.bin", &avsar)) {
+ printk(KERN_ERR
+ "avsar: Firmware not available\n");
+ device_unregister(&avsar);
+ return -1;
+ }
+ device_unregister(&avsar);
+ if(fw_entry->size > secLength) {
+ printk(KERN_ERR
+ "avsar: Firmware too big (%d bytes)\n", fw_entry->size);
+ release_firmware(fw_entry);
+ return -1;
+ }
+ memcpy(ptr + secOffset, fw_entry->data, secLength);
+ release_firmware(fw_entry);
+ return secLength;
}
int shim_osLoadDebugFWImage(unsigned char *ptr)
@@ -3064,6 +3015,7 @@ int tn7dsl_init(void *priv)
int high_precision_selected = 0;
// UR8_MERGE_END CQ11054*
+ sema_init(&adsl_sem_overlay, 0);
/*
* start dsl
*/
@@ -3442,7 +3394,7 @@ static int dslmod_sysctl(ctl_table *ctl,
*/
if(write)
{
- ret = proc_dostring(ctl, write, filp, buffer, lenp);
+ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
switch (ctl->ctl_name)
{
@@ -3528,14 +3480,14 @@ static int dslmod_sysctl(ctl_table *ctl,
else
{
len += sprintf(info+len, mod_req);
- ret = proc_dostring(ctl, write, filp, buffer, lenp);
+ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
}
return ret;
}
ctl_table dslmod_table[] = {
- {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, &dslmod_sysctl}
+ {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, NULL, &dslmod_sysctl, &sysctl_string}
,
{0}
};
@@ -3558,8 +3510,7 @@ void tn7dsl_dslmod_sysctl_register(void)
if (initialized == 1)
return;
- dslmod_sysctl_header = register_sysctl_table(dslmod_root_table, 1);
- dslmod_root_table->child->de->owner = THIS_MODULE;
+ dslmod_sysctl_header = register_sysctl_table(dslmod_root_table);
/*
* set the defaults
@@ -4821,4 +4772,4 @@ int tn7dsl_proc_PMDus(char* buf, char **
}
#endif //NO_ADV_STATS
#endif //TR69_PMD_IN
-// * UR8_MERGE_END CQ11057 *
\ No newline at end of file
+// * UR8_MERGE_END CQ11057 *
--- a/tn7sar.c
+++ b/tn7sar.c
@@ -42,7 +42,6 @@
* UR8_MERGE_END CQ10700
*******************************************************************************/
-#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
@@ -50,12 +49,13 @@
#include <linux/delay.h>
#include <linux/spinlock.h>
#include <linux/smp_lock.h>
-#include <asm/io.h>
-#include <asm/mips-boards/prom.h>
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <linux/ctype.h>
+#include <asm/io.h>
+#include <asm/ar7/ar7.h>
+#include <asm/ar7/prom.h>
#define _CPHAL_AAL5
#define _CPHAL_SAR

View File

@@ -1,37 +0,0 @@
--- a/tn7atm.c
+++ b/tn7atm.c
@@ -566,7 +566,7 @@ static int turbodsl_check_priority_type(
* Description: tnetd73xx SAR interrupt.
*
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-static void tn7atm_sar_irq (int irq, void *voiddev, struct pt_regs *regs)
+static irqreturn_t tn7atm_sar_irq (int irq, void *voiddev)
{
struct atm_dev *atmdev;
Tn7AtmPrivate *priv;
@@ -593,6 +593,7 @@ static void tn7atm_sar_irq (int irq, voi
#ifdef TIATM_INST_SUPP
psp_trace_par (ATM_DRV_SAR_ISR_EXIT, retval);
#endif
+ return IRQ_HANDLED;
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -602,7 +603,7 @@ static void tn7atm_sar_irq (int irq, voi
* Description: tnetd73xx DSL interrupt.
*
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-static void tn7atm_dsl_irq (int irq, void *voiddev, struct pt_regs *regs)
+static irqreturn_t tn7atm_dsl_irq (int irq, void *voiddev)
{
struct atm_dev *atmdev;
Tn7AtmPrivate *priv;
@@ -624,6 +625,8 @@ static void tn7atm_dsl_irq (int irq, voi
#ifdef TIATM_INST_SUPP
psp_trace_par (ATM_DRV_DSL_ISR_EXIT, retval);
#endif
+
+ return IRQ_HANDLED;
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -1,11 +0,0 @@
--- a/tn7api.h
+++ b/tn7api.h
@@ -107,7 +107,7 @@ int tn7dsl_proc_dbg_rmsgs4(char* buf, ch
int tn7dsl_proc_write_stats(struct file *fp, const char * buf, unsigned long count, void * data);
int tn7dsl_proc_modem(char* buf, char **start, off_t offset, int count,int *eof, void *data);
-inline int tn7dsl_handle_interrupt(void);
+int tn7dsl_handle_interrupt(void);
void tn7dsl_dslmod_sysctl_register(void);
void tn7dsl_dslmod_sysctl_unregister(void);

View File

@@ -1,44 +0,0 @@
--- a/dsl_hal_advcfg.c
+++ b/dsl_hal_advcfg.c
@@ -36,9 +36,9 @@
* 05Jul05 0.00.09 CPH CQ9775: Change dslhal_advcfg_configDsTones input parameters & support for ADSL2+
* 24Jul05 0.00.10 CPH Fixed comments in dslhal_advcfg_configDsTones function header
*******************************************************************************/
-#include <dev_host_interface.h>
-#include <dsl_hal_register.h>
-#include <dsl_hal_support.h>
+#include "dev_host_interface.h"
+#include "dsl_hal_register.h"
+#include "dsl_hal_support.h"
/*****************************************************************************/
/* ACT API functions -- To be moved into their own independent module --RamP */
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,7 @@
CONFIG_SANGAM_ATM=m
#EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
-EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
+#EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
+EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
obj-$(CONFIG_SANGAM_ATM) := tiatm.o
-tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o
+tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o dsl_hal_advcfg.o
--- a/tn7dsl.c
+++ b/tn7dsl.c
@@ -2869,6 +2869,14 @@ static int tn7dsl_set_dsl(void)
dslhal_api_setRateAdaptFlag(pIhw, os_atoi(ptr));
}
+ // set powercutback
+ ptr = NULL;
+ ptr = prom_getenv("powercutback");
+ if(ptr)
+ {
+ dslhal_advcfg_onOffPcb(pIhw, os_atoi(ptr));
+ }
+
// trellis
ptr = NULL;
ptr = prom_getenv("trellis");

View File

@@ -1,16 +0,0 @@
--- a/tn7sar.c
+++ b/tn7sar.c
@@ -103,10 +103,10 @@ enum
#define RESERVED_OAM_CHANNEL 15
-#define AAL5_PARM "id=aal5, base = 0x03000000, offset = 0, int_line=15, ch0=[RxBufSize=1522; RxNumBuffers = 32; RxServiceMax = 50; TxServiceMax=50; TxNumBuffers=32; CpcsUU=0x5aa5; TxVc_CellRate=0x3000; TxVc_AtmHeader=0x00000640]"
-#define SAR_PARM "id=sar,base = 0x03000000, reset_bit = 9, offset = 0; UniNni = 0, PdspEnable = 1"
+#define CH0_PARM "RxBufSize=1522, RxNumBuffers=32, RxServiceMax=50, TxServiceMax=50, TxNumBuffers=32, CpcsUU=0x5aa5, TxVc_CellRate=0x3000, TxVc_AtmHeader=0x00000640"
+#define AAL5_PARM "id=aal5, base=0x03000000, offset=0, int_line=15, ch0=[" CH0_PARM "]"
+#define SAR_PARM "id=sar, base=0x03000000, reset_bit=9, offset=0; UniNni=0, PdspEnable=1, Debug=0xFFFFFFFF"
#define RESET_PARM "id=ResetControl, base=0xA8611600"
-#define CH0_PARM "RxBufSize=1522, RxNumBuffers = 32, RxServiceMax = 50, TxServiceMax=50, TxNumBuffers=32, CpcsUU=0x5aa5, TxVc_CellRate=0x3000, TxVc_AtmHeader=0x00000640"
#define MAX_PVC_TABLE_ENTRY 16

View File

@@ -1,11 +0,0 @@
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,7 @@
CONFIG_SANGAM_ATM=m
#EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
#EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
-EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
+#EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
+EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL -DCPATM_TASKLET_MODE
obj-$(CONFIG_SANGAM_ATM) := tiatm.o
tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o dsl_hal_advcfg.o

View File

@@ -1,589 +0,0 @@
--- a/tn7atm.c
+++ b/tn7atm.c
@@ -87,6 +87,146 @@
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION ("Tnetd73xx ATM Device Driver");
MODULE_AUTHOR ("Zhicheng Tang");
+
+int mp_sar_ipacemax = -1;
+module_param_named(ipacemax, mp_sar_ipacemax, int, 0);
+MODULE_PARM_DESC(ipacemax, "Interrupt pacing");
+
+char *mp_macc = NULL;
+module_param_named(macc, mp_macc, charp, 0);
+MODULE_PARM_DESC(macc, "MAC address");
+
+int mp_dsp_noboost = -1;
+module_param_named(dsp_noboost, mp_dsp_noboost, int, 0);
+MODULE_PARM_DESC(dsp_noboost, "Suppress DSP frequency boost");
+
+int mp_dsp_freq = -1;
+module_param_named(dsp_freq, mp_dsp_freq, int, 0);
+MODULE_PARM_DESC(dsp_freq, "Frequency to boost the DSP to");
+
+char *mp_featctl0 = NULL;
+module_param_named(featctl0, mp_featctl0, charp, 0);
+MODULE_PARM_DESC(featctl0, "DSL feature control 0");
+
+char *mp_featctl1 = NULL;
+module_param_named(featctl1, mp_featctl1, charp, 0);
+MODULE_PARM_DESC(featctl1, "DSL feature control 1");
+
+char *mp_phyctl0 = NULL;
+module_param_named(phyctl0, mp_phyctl0, charp, 0);
+MODULE_PARM_DESC(phyctl0, "DSL PHY control 0");
+
+char *mp_phyctl1 = NULL;
+module_param_named(phyctl1, mp_phyctl1, charp, 0);
+MODULE_PARM_DESC(phyctl1, "DSL PHY control 1");
+
+int mp_turbodsl = -1;
+module_param_named(turbodsl, mp_turbodsl, int, 0);
+MODULE_PARM_DESC(turbodsl, "Enable TurboDSL");
+
+int mp_sar_rxbuf = -1;
+module_param_named(sar_rxbuf, mp_sar_rxbuf, int, 0);
+MODULE_PARM_DESC(sar_rxbuf, "SAR RxBuf size");
+
+int mp_sar_rxmax = -1;
+module_param_named(sar_rxmax, mp_sar_rxmax, int, 0);
+MODULE_PARM_DESC(sar_rxmax, "SAR RxMax size");
+
+int mp_sar_txbuf = -1;
+module_param_named(sar_txbuf, mp_sar_txbuf, int, 0);
+MODULE_PARM_DESC(sar_txbuf, "SAR TxBuf size");
+
+int mp_sar_txmax = -1;
+module_param_named(sar_txmax, mp_sar_txmax, int, 0);
+MODULE_PARM_DESC(sar_txmax, "SAR TxMax size");
+
+char *mp_modulation = NULL;
+module_param_named(modulation, mp_modulation, charp, 0);
+MODULE_PARM_DESC(modulation, "Modulation");
+
+int mp_fine_gain_control = -1;
+module_param_named(fine_gain_control, mp_fine_gain_control, int, 0);
+MODULE_PARM_DESC(fine_gain_control, "Fine gain control");
+
+int mp_fine_gain_value = -1;
+module_param_named(fine_gain_value, mp_fine_gain_value, int, 0);
+MODULE_PARM_DESC(fine_gain_value, "Fine gain value");
+
+int mp_enable_margin_retrain = -1;
+module_param_named(enable_margin_retrain, mp_enable_margin_retrain, int, 0);
+MODULE_PARM_DESC(enable_margin_retrain, "Enable margin retrain");
+
+int mp_margin_threshold = -1;
+module_param_named(margin_threshold, mp_margin_threshold, int, 0);
+MODULE_PARM_DESC(margin_threshold, "Margin retrain treshold");
+
+int mp_enable_rate_adapt = -1;
+module_param_named(enable_rate_adapt, mp_enable_rate_adapt, int, 0);
+MODULE_PARM_DESC(enable_rate_adapt, "Enable rate adaption");
+
+int mp_powercutback = -1;
+module_param_named(powercutback, mp_powercutback, int, 0);
+MODULE_PARM_DESC(powercutback, "Enable / disable powercutback");
+
+int mp_trellis = -1;
+module_param_named(trellis, mp_trellis, int, 0);
+MODULE_PARM_DESC(trellis, "Enable / disable trellis coding");
+
+int mp_bitswap = -1;
+module_param_named(bitswap, mp_bitswap, int, 0);
+MODULE_PARM_DESC(bitswap, "Enable / disable bitswap");
+
+int mp_maximum_bits_per_carrier = -1;
+module_param_named(maximum_bits_per_carrier, mp_maximum_bits_per_carrier, int, 0);
+MODULE_PARM_DESC(maximum_bits_per_carrier, "Maximum bits per carrier");
+
+int mp_maximum_interleave_depth = -1;
+module_param_named(maximum_interleave_depth, mp_maximum_interleave_depth, int, 0);
+MODULE_PARM_DESC(maximum_interleave_depth, "Maximum interleave depth");
+
+int mp_pair_selection = -1;
+module_param_named(pair_selection, mp_pair_selection, int, 0);
+MODULE_PARM_DESC(pair_selection, "Pair selection");
+
+int mp_dgas_polarity = -1;
+module_param_named(dgas_polarity, mp_dgas_polarity, int, 0);
+MODULE_PARM_DESC(dgas_polarity, "DGAS polarity");
+
+int mp_los_alarm = -1;
+module_param_named(los_alarm, mp_los_alarm, int, 0);
+MODULE_PARM_DESC(los_alarm, "LOS alarm");
+
+char *mp_eoc_vendor_id = NULL;
+module_param_named(eoc_vendor_id, mp_eoc_vendor_id, charp, 0);
+MODULE_PARM_DESC(eoc_vendor_id, "EOC vendor id");
+
+int mp_eoc_vendor_revision = -1;
+module_param_named(eoc_vendor_revision, mp_eoc_vendor_revision, int, 0);
+MODULE_PARM_DESC(eoc_vendor_revision, "EOC vendor revision");
+
+char *mp_eoc_vendor_serialnum = NULL;
+module_param_named(eoc_vendor_serialnum, mp_eoc_vendor_serialnum, charp, 0);
+MODULE_PARM_DESC(eoc_vendor_serialnum, "EOC vendor serial number");
+
+char *mp_invntry_vernum = NULL;
+module_param_named(invntry_vernum, mp_invntry_vernum, charp, 0);
+MODULE_PARM_DESC(invntry_vernum, "Inventory revision number");
+
+int mp_dsl_bit_tmode = -1;
+module_param_named(dsl_bit_tmode, mp_dsl_bit_tmode, int, 0);
+MODULE_PARM_DESC(dsl_bit_tmode, "DSL bit training mode");
+
+int mp_high_precision = -1;
+module_param_named(high_precision, mp_high_precision, int, 0);
+MODULE_PARM_DESC(high_precision, "High precision");
+
+int mp_autopvc_enable = -1;
+module_param_named(autopvc_enable, mp_autopvc_enable, int, 0);
+MODULE_PARM_DESC(autopvc_enable, "Enable / disable automatic PVC");
+
+int mp_oam_lb_timeout = -1;
+module_param_named(oam_lb_timeout, mp_oam_lb_timeout, int, 0);
+MODULE_PARM_DESC(oam_lb_timeout, "OAM LB timeout");
#endif
#ifndef TRUE
@@ -655,9 +795,9 @@
* interrupt pacing
*/
ptr = prom_getenv ("sar_ipacemax");
- if (ptr)
+ if (ptr || mp_sar_ipacemax != -1)
{
- def_sar_inter_pace = os_atoi (ptr);
+ def_sar_inter_pace = mp_sar_ipacemax == -1 ? os_atoi (ptr) : mp_sar_ipacemax;
}
/* avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
def_sar_inter_pace);*/
@@ -795,9 +935,18 @@
{
int i;
char esi_addr[ESI_LEN] = { 0x00, 0x00, 0x11, 0x22, 0x33, 0x44 };
- char *esiaddr_str = NULL;
+ char *esiaddr_str = mp_macc;
- esiaddr_str = prom_getenv ("maca");
+ if (esiaddr_str == NULL)
+ esiaddr_str = prom_getenv ("macdsl");
+ if (esiaddr_str == NULL)
+ esiaddr_str = prom_getenv ("macc");
+ if (esiaddr_str == NULL)
+ esiaddr_str = prom_getenv ("HWA_1");
+ if (esiaddr_str == NULL)
+ esiaddr_str = prom_getenv ("macb");
+ if (esiaddr_str == NULL)
+ esiaddr_str = prom_getenv ("maca");
if (!esiaddr_str)
{
@@ -1930,15 +2079,15 @@
//UR8_MERGE_END CQ10450*
cp = prom_getenv ("dsp_noboost");
- if (cp)
+ if (cp || mp_dsp_noboost != -1)
{
- dsp_noboost = os_atoi (cp);
+ dsp_noboost = mp_dsp_noboost == -1 ? os_atoi (cp) : mp_dsp_noboost;
}
cp = (char *) prom_getenv ("dsp_freq");
- if (cp)
+ if (cp || mp_dsp_freq != -1)
{
- dspfreq = os_atoi (cp);
+ dspfreq = mp_dsp_freq == -1 ? os_atoi (cp) : mp_dsp_freq;
if (dspfreq == 250)
{
boostDsp = 1;
@@ -2187,8 +2336,9 @@
// Inter-Op DSL phy Control
// Note the setting of _dsl_Feature_0 and _dsl_Feature_1 must before
// dslhal_api_dslStartup (in tn7dsl_init()).
- if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_0")) != NULL)
+ if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_0")) != NULL || mp_featctl0 != NULL)
{
+ if (mp_featctl0 != NULL) ptr = mp_featctl0;
if ((ptr[0] == '0') && (ptr[1] == 'x')) // skip 0x before pass to
// os_atoh
ptr += 2;
@@ -2196,8 +2346,9 @@
_dsl_Feature_0_defined = 1;
}
- if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_1")) != NULL)
+ if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_1")) != NULL || mp_featctl1 != NULL)
{
+ if (mp_featctl1 != NULL) ptr = mp_featctl1;
if ((ptr[0] == '0') && (ptr[1] == 'x')) // skip 0x before pass to
// os_atoh
ptr += 2;
@@ -2209,8 +2360,9 @@
// DSL phy Feature Control
// Note the setting of _dsl_PhyControl_0 and _dsl_PhyControl_1 must before
// dslhal_api_dslStartup (in tn7dsl_init()).
- if ((ptr = prom_getenv ("DSL_PHY_CNTL_0")) != NULL)
+ if ((ptr = prom_getenv ("DSL_PHY_CNTL_0")) != NULL || mp_phyctl0 != NULL)
{
+ if (mp_phyctl0 != NULL) ptr = mp_phyctl0;
if ((ptr[0] == '0') && (ptr[1] == 'x')) // skip 0x before pass to
// os_atoh
ptr += 2;
@@ -2218,8 +2370,9 @@
_dsl_PhyControl_0_defined = 1;
}
- if ((ptr = prom_getenv ("DSL_PHY_CNTL_1")) != NULL)
+ if ((ptr = prom_getenv ("DSL_PHY_CNTL_1")) != NULL || mp_phyctl1 != NULL)
{
+ if (mp_phyctl1 != NULL) ptr = mp_phyctl1;
if ((ptr[0] == '0') && (ptr[1] == 'x')) // skip 0x before pass to
// os_atoh
ptr += 2;
@@ -2247,9 +2400,9 @@
priv->bTurboDsl = 1;
// read config for turbo dsl
ptr = prom_getenv ("TurboDSL");
- if (ptr)
+ if (ptr || mp_turbodsl != -1)
{
- priv->bTurboDsl = os_atoi (ptr);
+ priv->bTurboDsl = mp_turbodsl == -1 ? os_atoi (ptr) : mp_turbodsl;
}
// @Added to make Rx buffer number & Service max configurable through
@@ -2257,30 +2410,30 @@
priv->sarRxBuf = RX_BUFFER_NUM;
ptr = NULL;
ptr = prom_getenv ("SarRxBuf");
- if (ptr)
+ if (ptr || mp_sar_rxbuf != -1)
{
- priv->sarRxBuf = os_atoi (ptr);
+ priv->sarRxBuf = mp_sar_rxbuf == -1 ? os_atoi (ptr) : mp_sar_rxbuf;
}
priv->sarRxMax = RX_SERVICE_MAX;
ptr = NULL;
ptr = prom_getenv ("SarRxMax");
- if (ptr)
+ if (ptr || mp_sar_rxmax != -1)
{
- priv->sarRxMax = os_atoi (ptr);
+ priv->sarRxMax = mp_sar_rxmax == -1 ? os_atoi (ptr) : mp_sar_rxmax;
}
priv->sarTxBuf = TX_BUFFER_NUM;
ptr = NULL;
ptr = prom_getenv ("SarTxBuf");
- if (ptr)
+ if (ptr || mp_sar_txbuf != -1)
{
- priv->sarTxBuf = os_atoi (ptr);
+ priv->sarTxBuf = mp_sar_txbuf == -1 ? os_atoi (ptr) : mp_sar_txbuf;
}
priv->sarTxMax = TX_SERVICE_MAX;
ptr = NULL;
ptr = prom_getenv ("SarTxMax");
- if (ptr)
+ if (ptr || mp_sar_txmax != -1)
{
- priv->sarTxMax = os_atoi (ptr);
+ priv->sarTxMax = mp_sar_txmax == -1 ? os_atoi (ptr) : mp_sar_txmax;
}
return 0;
--- a/tn7dsl.c
+++ b/tn7dsl.c
@@ -136,6 +136,27 @@
#define NEW_TRAINING_VAL_T1413 128
#define NEW_TRAINING_VAL_MMODE 255
+extern char *mp_modulation;
+extern int mp_fine_gain_control;
+extern int mp_fine_gain_value;
+extern int mp_enable_margin_retrain;
+extern int mp_margin_threshold;
+extern int mp_enable_rate_adapt;
+extern int mp_powercutback;
+extern int mp_trellis;
+extern int mp_bitswap;
+extern int mp_maximum_bits_per_carrier;
+extern int mp_maximum_interleave_depth;
+extern int mp_pair_selection;
+extern int mp_dgas_polarity;
+extern int mp_los_alarm;
+extern char *mp_eoc_vendor_id;
+extern int mp_eoc_vendor_revision;
+extern char *mp_eoc_vendor_serialnum;
+extern char *mp_invntry_vernum;
+extern int mp_dsl_bit_tmode;
+extern int mp_high_precision;
+
int testflag1 = 0;
extern int __guDbgLevel;
extern sar_stat_t sarStat;
@@ -2818,84 +2839,80 @@ static int tn7dsl_set_dsl(void)
// modulation
ptr = prom_getenv("modulation");
- if (ptr)
+ if (ptr || mp_modulation != NULL)
{
- tn7dsl_set_modulation(ptr, FALSE);
+ tn7dsl_set_modulation(mp_modulation == NULL ? ptr : mp_modulation, FALSE);
}
// Fine Gains
ptr = prom_getenv("fine_gain_control");
- if (ptr)
+ if (ptr || mp_fine_gain_control != -1)
{
- value = os_atoi(ptr);
+ value = mp_fine_gain_control == -1 ? os_atoi(ptr) : mp_fine_gain_control;
tn7dsl_ctrl_fineGain(value);
}
ptr = NULL;
ptr = prom_getenv("fine_gain_value");
- if(ptr)
- tn7dsl_set_fineGainValue(os_atoh(ptr));
+ if(ptr || mp_fine_gain_value != -1)
+ tn7dsl_set_fineGainValue(mp_fine_gain_value == -1 ? os_atoh(ptr) : mp_fine_gain_value);
// margin retrain
ptr = NULL;
ptr = prom_getenv("enable_margin_retrain");
- if(ptr)
+ value = mp_enable_margin_retrain == -1 ? (ptr ? os_atoi(ptr) : 0) : mp_enable_margin_retrain;
+
+ if (value == 1)
{
- value = os_atoi(ptr);
- if(value == 1)
+ dslhal_api_setMarginMonitorFlags(pIhw, 0, 1);
+ bMarginRetrainEnable = 1;
+ //printk("enable showtime margin monitor.\n");
+
+ ptr = NULL;
+ ptr = prom_getenv("margin_threshold");
+ value = mp_margin_threshold == -1 ? (ptr ? os_atoi(ptr) : 0) : mp_margin_threshold;
+
+ if(value >= 0)
{
- dslhal_api_setMarginMonitorFlags(pIhw, 0, 1);
- bMarginRetrainEnable = 1;
- //printk("enable showtime margin monitor.\n");
- ptr = NULL;
- ptr = prom_getenv("margin_threshold");
- if(ptr)
- {
- value = os_atoi(ptr);
- //printk("Set margin threshold to %d x 0.5 db\n",value);
- if(value >= 0)
- {
- dslhal_api_setMarginThreshold(pIhw, value);
- bMarginThConfig=1;
- }
- }
+ dslhal_api_setMarginThreshold(pIhw, value);
+ bMarginThConfig=1;
}
}
// rate adapt
ptr = NULL;
ptr = prom_getenv("enable_rate_adapt");
- if(ptr)
+ if(ptr || mp_enable_rate_adapt != -1)
{
- dslhal_api_setRateAdaptFlag(pIhw, os_atoi(ptr));
+ dslhal_api_setRateAdaptFlag(pIhw, mp_enable_rate_adapt == -1 ? os_atoi(ptr) : mp_enable_rate_adapt);
}
// set powercutback
ptr = NULL;
ptr = prom_getenv("powercutback");
- if(ptr)
+ if(ptr || mp_powercutback != -1)
{
- dslhal_advcfg_onOffPcb(pIhw, os_atoi(ptr));
+ dslhal_advcfg_onOffPcb(pIhw, mp_powercutback == -1 ? os_atoi(ptr) : mp_powercutback);
}
// trellis
ptr = NULL;
ptr = prom_getenv("trellis");
- if(ptr)
+ if(ptr || mp_trellis != -1)
{
- dslhal_api_setTrellisFlag(pIhw, os_atoi(ptr));
- trellis = os_atoi(ptr);
+ trellis = mp_trellis == -1 ? os_atoi(ptr) : mp_trellis;
+ dslhal_api_setTrellisFlag(pIhw, trellis);
//printk("trellis=%d\n");
}
// bitswap
ptr = NULL;
ptr = prom_getenv("bitswap");
- if(ptr)
+ if(ptr || mp_bitswap != -1)
{
int offset[2] = {33, 0};
unsigned int bitswap;
- bitswap = os_atoi(ptr);
+ bitswap = mp_bitswap == -1 ? os_atoi(ptr) : mp_bitswap;
tn7dsl_generic_read(2, offset);
dslReg &= dslhal_support_byteSwap32(0xFFFFFF00);
@@ -2913,46 +2930,47 @@ static int tn7dsl_set_dsl(void)
// maximum bits per carrier
ptr = NULL;
ptr = prom_getenv("maximum_bits_per_carrier");
- if(ptr)
+ if(ptr || mp_maximum_bits_per_carrier != -1)
{
- dslhal_api_setMaxBitsPerCarrierUpstream(pIhw, os_atoi(ptr));
+ dslhal_api_setMaxBitsPerCarrierUpstream(pIhw, mp_maximum_bits_per_carrier == -1 ? os_atoi(ptr) : mp_maximum_bits_per_carrier);
}
// maximum interleave depth
ptr = NULL;
ptr = prom_getenv("maximum_interleave_depth");
- if(ptr)
+ if(ptr || mp_maximum_interleave_depth != -1)
{
- dslhal_api_setMaxInterleaverDepth(pIhw, os_atoi(ptr));
+ dslhal_api_setMaxInterleaverDepth(pIhw, mp_maximum_interleave_depth == -1 ? os_atoi(ptr) : mp_maximum_interleave_depth);
}
// inner and outer pairs
ptr = NULL;
ptr = prom_getenv("pair_selection");
- if(ptr)
+ if(ptr || mp_pair_selection != -1)
{
- dslhal_api_selectInnerOuterPair(pIhw, os_atoi(ptr));
+ dslhal_api_selectInnerOuterPair(pIhw, mp_pair_selection == -1 ? os_atoi(ptr) : mp_pair_selection);
}
ptr = NULL;
ptr = prom_getenv("dgas_polarity");
- if(ptr)
+ if(ptr || mp_dgas_polarity != -1)
{
dslhal_api_configureDgaspLpr(pIhw, 1, 1);
- dslhal_api_configureDgaspLpr(pIhw, 0, os_atoi(ptr));
+ dslhal_api_configureDgaspLpr(pIhw, 0, mp_dgas_polarity == -1 ? os_atoi(ptr) : mp_dgas_polarity);
}
ptr = NULL;
ptr = prom_getenv("los_alarm");
- if(ptr)
+ if(ptr || mp_los_alarm != -1)
{
- dslhal_api_disableLosAlarm(pIhw, os_atoi(ptr));
+ dslhal_api_disableLosAlarm(pIhw, mp_los_alarm == -1 ? os_atoi(ptr) : mp_los_alarm);
}
ptr = NULL;
ptr = prom_getenv("eoc_vendor_id");
- if(ptr)
+ if(ptr || mp_eoc_vendor_id != NULL)
{
+ ptr = mp_eoc_vendor_id == NULL ? ptr : mp_eoc_vendor_id;
for(i=0;i<8;i++)
{
tmp[0]=ptr[i*2];
@@ -2977,26 +2995,26 @@ static int tn7dsl_set_dsl(void)
}
ptr = NULL;
ptr = prom_getenv("eoc_vendor_revision");
- if(ptr)
+ if(ptr || mp_eoc_vendor_revision != -1)
{
- value = os_atoi(ptr);
+ value = mp_eoc_vendor_revision == -1 ? os_atoi(ptr) : mp_eoc_vendor_revision;
//printk("eoc rev=%d\n", os_atoi(ptr));
dslhal_api_setEocRevisionNumber(pIhw, (char *)&value);
}
ptr = NULL;
ptr = prom_getenv("eoc_vendor_serialnum");
- if(ptr)
+ if(ptr || mp_eoc_vendor_serialnum != NULL)
{
- dslhal_api_setEocSerialNumber(pIhw, ptr);
+ dslhal_api_setEocSerialNumber(pIhw, mp_eoc_vendor_serialnum == NULL ? ptr : mp_eoc_vendor_serialnum);
}
// CQ10037 Added invntry_vernum environment variable to be able to set version number in ADSL2, ADSL2+ modes.
ptr = NULL;
ptr = prom_getenv("invntry_vernum");
- if(ptr)
+ if(ptr || mp_invntry_vernum != NULL)
{
- dslhal_api_setEocRevisionNumber(pIhw, ptr);
+ dslhal_api_setEocRevisionNumber(pIhw, mp_invntry_vernum == NULL ? ptr : mp_invntry_vernum);
}
return 0;
@@ -3041,7 +3059,7 @@ int tn7dsl_init(void *priv)
* backward compatibility.
*/
cp = prom_getenv("DSL_BIT_TMODE");
- if (cp)
+ if (cp || mp_dsl_bit_tmode != -1)
{
printk("%s : env var DSL_BIT_TMODE is set\n", __FUNCTION__);
/*
@@ -3070,9 +3088,9 @@ int tn7dsl_init(void *priv)
// UR8_MERGE_START CQ11054 Jack Zhang
cp = prom_getenv("high_precision");
- if (cp)
+ if (cp || mp_high_precision != -1)
{
- high_precision_selected = os_atoi(cp);
+ high_precision_selected = mp_high_precision == -1 ? os_atoi(cp) : mp_high_precision;
}
if ( high_precision_selected)
{
--- a/tn7sar.c
+++ b/tn7sar.c
@@ -74,6 +74,8 @@ typedef void OS_SETUP;
/* PDSP Firmware files */
#include "tnetd7300_sar_firm.h"
+extern int mp_oam_lb_timeout;
+extern int mp_autopvc_enable;
enum
{
@@ -817,9 +819,9 @@ int tn7sar_setup_oam_channel(Tn7AtmPriva
pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
pauto_pvc = prom_getenv("autopvc_enable");
- if(pauto_pvc) //CQ10273
+ if(pauto_pvc || mp_autopvc_enable != -1) //CQ10273
{
- auto_pvc =tn7sar_strtoul(pauto_pvc, NULL, 10);
+ auto_pvc = mp_autopvc_enable == -1 ? tn7sar_strtoul(pauto_pvc, NULL, 10) : mp_autopvc_enable;
}
memset(&chInfo, 0xff, sizeof(chInfo));
@@ -985,9 +987,9 @@ int tn7sar_init(struct atm_dev *dev, Tn7
/* read in oam lb timeout value */
pLbTimeout = prom_getenv("oam_lb_timeout");
- if(pLbTimeout)
+ if(pLbTimeout || mp_oam_lb_timeout != -1)
{
- lbTimeout =tn7sar_strtoul(pLbTimeout, NULL, 10);
+ lbTimeout = mp_oam_lb_timeout == -1 ? tn7sar_strtoul(pLbTimeout, NULL, 10) : mp_oam_lb_timeout;
oamLbTimeout = lbTimeout;
pHalFunc->Control(pHalDev,"OamLbTimeout", "Set", &lbTimeout);
}

View File

@@ -1,30 +0,0 @@
--- a/tn7dsl.c
+++ b/tn7dsl.c
@@ -109,6 +109,7 @@
#include <linux/vmalloc.h>
#include <linux/file.h>
#include <linux/firmware.h>
+#include <linux/version.h>
#include <asm/io.h>
#include <asm/ar7/ar7.h>
@@ -446,7 +447,9 @@ static void avsar_release(struct device
}
static struct device avsar = {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
.bus_id = "vlynq",
+#endif
.release = avsar_release,
};
@@ -455,6 +458,9 @@ int shim_osLoadFWImage(unsigned char *pt
const struct firmware *fw_entry;
size_t size;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
+ dev_set_name(&avsar, "avsar");
+#endif
printk("requesting firmware image \"ar0700xx.bin\"\n");
if(device_register(&avsar) < 0) {
printk(KERN_ERR

View File

@@ -1,54 +0,0 @@
--- a/tn7atm.c
+++ b/tn7atm.c
@@ -71,10 +71,16 @@
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <linux/ctype.h>
+#include <linux/version.h>
#include <asm/io.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
#include <asm/ar7/ar7.h>
#include <asm/ar7/prom.h>
+#else
+#include <asm/mach-ar7/ar7.h>
+#include <asm/mach-ar7/prom.h>
+#endif
#include "dsl_hal_api.h"
#include "tn7atm.h"
--- a/tn7dsl.c
+++ b/tn7dsl.c
@@ -112,8 +112,13 @@
#include <linux/version.h>
#include <asm/io.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
#include <asm/ar7/ar7.h>
#include <asm/ar7/prom.h>
+#else
+#include <asm/mach-ar7/ar7.h>
+#include <asm/mach-ar7/prom.h>
+#endif
/* Modules specific header files */
#include "tn7atm.h"
--- a/tn7sar.c
+++ b/tn7sar.c
@@ -52,10 +52,16 @@
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <linux/ctype.h>
+#include <linux/version.h>
#include <asm/io.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
#include <asm/ar7/ar7.h>
#include <asm/ar7/prom.h>
+#else
+#include <asm/mach-ar7/ar7.h>
+#include <asm/mach-ar7/prom.h>
+#endif
#define _CPHAL_AAL5
#define _CPHAL_SAR

View File

@@ -1,79 +0,0 @@
--- a/tn7dsl.c
+++ b/tn7dsl.c
@@ -203,7 +203,11 @@ led_reg_t ledreg[2];
static struct led_funcs ledreg[2];
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
#define DEV_DSLMOD CTL_UNNUMBERED
+#else
+#define DEV_DSLMOD 0
+#endif
#define MAX_STR_SIZE 256
#define DSL_MOD_SIZE 256
@@ -3431,9 +3435,16 @@ static int dslmod_sysctl(ctl_table *ctl,
*/
if(write)
{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
-
+#else
+ ret = proc_dostring(ctl, write, buffer, lenp, 0);
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
switch (ctl->ctl_name)
+#else
+ switch ((long)ctl->extra2)
+#endif
{
case DEV_DSLMOD:
ptr = strpbrk(info, " \t");
@@ -3517,14 +3528,29 @@ static int dslmod_sysctl(ctl_table *ctl,
else
{
len += sprintf(info+len, mod_req);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
+#else
+ ret = proc_dostring(ctl, write, buffer, lenp, 0);
+#endif
}
return ret;
}
ctl_table dslmod_table[] = {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
{DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, NULL, &dslmod_sysctl, &sysctl_string}
+#else
+ {
+ .procname = "dslmod",
+ .data = info,
+ .maxlen = DSL_MOD_SIZE,
+ .mode = 0644,
+ .proc_handler = &dslmod_sysctl,
+ .extra2 = (void *)DEV_DSLMOD,
+ }
+#endif
,
{0}
};
@@ -3532,7 +3558,16 @@ ctl_table dslmod_table[] = {
/* Make sure that /proc/sys/dev is there */
ctl_table dslmod_root_table[] = {
#ifdef CONFIG_PROC_FS
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
{CTL_DEV, "dev", NULL, 0, 0555, dslmod_table}
+ #else
+ {
+ .procname = "dev",
+ .maxlen = 0,
+ .mode = 0555,
+ .child = dslmod_table,
+ }
+ #endif
,
#endif /* CONFIG_PROC_FS */
{0}

View File

@@ -1,36 +0,0 @@
--- a/tn7atm.c
+++ b/tn7atm.c
@@ -1867,7 +1867,11 @@ static int __init tn7atm_register (Tn7At
dgprintf (4, "device %s being registered\n", priv->name);
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
mydev = atm_dev_register (priv->proc_name, &tn7atm_ops, -1, NULL);
+ #else
+ mydev = atm_dev_register (priv->proc_name, NULL, &tn7atm_ops, -1, NULL);
+ #endif
if (mydev == NULL)
{
--- a/tn7dsl.c
+++ b/tn7dsl.c
@@ -466,14 +466,17 @@ int shim_osLoadFWImage(unsigned char *pt
{
const struct firmware *fw_entry;
size_t size;
+ int ret;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
dev_set_name(&avsar, "avsar");
#endif
printk("requesting firmware image \"ar0700xx.bin\"\n");
- if(device_register(&avsar) < 0) {
+ dev_set_name(&avsar, "avsar");
+ ret = device_register(&avsar);
+ if (ret < 0) {
printk(KERN_ERR
- "avsar: device_register fails\n");
+ "avsar: device_register fails, error%i\n", ret);
return -1;
}

View File

@@ -1,33 +0,0 @@
--- a/tn7atm.c
+++ b/tn7atm.c
@@ -67,7 +67,7 @@
#include <linux/atmdev.h>
#include <linux/delay.h>
#include <linux/spinlock.h>
-#include <linux/smp_lock.h>
+#include <linux/interrupt.h>
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <linux/ctype.h>
--- a/tn7sar.c
+++ b/tn7sar.c
@@ -48,7 +48,7 @@
#include <linux/atmdev.h>
#include <linux/delay.h>
#include <linux/spinlock.h>
-#include <linux/smp_lock.h>
+#include <linux/interrupt.h>
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <linux/ctype.h>
--- a/tn7dsl.c
+++ b/tn7dsl.c
@@ -100,7 +100,7 @@
#include <linux/atmdev.h>
#include <linux/delay.h>
#include <linux/spinlock.h>
-#include <linux/smp_lock.h>
+#include <linux/interrupt.h>
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <linux/ctype.h>

View File

@@ -1,808 +0,0 @@
--- a/cppi_cpaal5.c
+++ b/cppi_cpaal5.c
@@ -360,7 +360,7 @@ static int halRxReturn(HAL_RECEIVEINFO *
{
/* malloc failed, add this RCB to Needs Buffer List */
TempRcb->FragCount = 1; /*MJH+030417*/
- (HAL_RCB *)TempRcb->Eop = TempRcb; /* GSG +030430 */
+ TempRcb->Eop = TempRcb; /* GSG +030430 */
if(HalDev->NeedsCount < MAX_NEEDS) /* +MJH 030410 */
{ /* +MJH 030410 */
--- a/dsl_hal_api.c
+++ b/dsl_hal_api.c
@@ -273,15 +273,15 @@
* 09/15/07 CPH CQ11466 Added EFM support
* 09/27/07 EYin CQ11929: Added NFEC/INP/Lp/Rp reporting for only ADSL2/2+ mode.
******************************************************************************/
-#include <dev_host_interface.h>
-#include <dsl_hal_register.h>
-#include <dsl_hal_support.h>
+#include "dev_host_interface.h"
+#include "dsl_hal_register.h"
+#include "dsl_hal_support.h"
#ifndef NO_ADV_STATS
-#include <dsl_hal_logtable.h>
+#include "dsl_hal_logtable.h"
#endif
-#include <dsl_hal_version.h>
+#include "dsl_hal_version.h"
// UR8_MERGE_START CQ11054 Jack Zhang
static unsigned int highprecision_selected = 0; //By default we use low precision for backward compt.
--- a/dsl_hal_support.c
+++ b/dsl_hal_support.c
@@ -142,9 +142,9 @@
* UR8_MERGE_START_END CQ11922 Tim
* 04Sep07 0.14.00 Tim CQ11922: Added support for new scratchram for INP NDR tables
*******************************************************************************/
-#include <dev_host_interface.h>
-#include <dsl_hal_register.h>
-#include <dsl_hal_support.h>
+#include "dev_host_interface.h"
+#include "dsl_hal_register.h"
+#include "dsl_hal_support.h"
#define NUM_READ_RETRIES 3
static unsigned int dslhal_support_adsl2ByteSwap32(unsigned int in32Bits);
--- a/dsl_hal_support.h
+++ b/dsl_hal_support.h
@@ -49,7 +49,7 @@
* 04Nov05 0.11.00 CPH Fixed T1413 mode got Zero DS/US rate when DSL_BIT_TMODE is set.
*******************************************************************************/
-#include <dsl_hal_api.h>
+#include "dsl_hal_api.h"
#define virtual2Physical(a) (((int)a)&~0xe0000000)
/* External Function Prototype Declarations */
--- a/Makefile
+++ b/Makefile
@@ -1,18 +1,9 @@
-# File: drivers/atm/ti_evm3/Makefile
#
-# Makefile for the Texas Instruments EVM3 ADSL/ATM driver.
+# Makefile for the TIATM device driver.
#
-#
-# Copyright (c) 2000 Texas Instruments Incorporated.
-# Jeff Harrell (jharrell@telogy.com)
-# Viren Balar (vbalar@ti.com)
-# Victor Wells (vwells@telogy.com)
-#
-include $(TOPDIR)/Rules.make
-
-
-
-
-
-
+CONFIG_SANGAM_ATM=m
+#EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
+EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
+obj-$(CONFIG_SANGAM_ATM) := tiatm.o
+tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o
--- a/tn7atm.c
+++ b/tn7atm.c
@@ -66,7 +66,6 @@
* 09/18/07 CPH CQ11466 Added EFM Support
*********************************************************************************************/
-#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
@@ -74,11 +73,14 @@
#include <linux/delay.h>
#include <linux/spinlock.h>
#include <linux/smp_lock.h>
-#include <asm/io.h>
-#include <asm/mips-boards/prom.h>
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <linux/ctype.h>
+
+#include <asm/io.h>
+#include <asm/ar7/ar7.h>
+#include <asm/ar7/prom.h>
+
#include "dsl_hal_api.h"
#ifdef AR7_EFM
#include "tn7efm.h"
@@ -90,6 +92,7 @@
#include "dsl_hal_register.h"
#ifdef MODULE
+MODULE_LICENSE("GPL");
MODULE_DESCRIPTION ("Tnetd73xx ATM Device Driver");
MODULE_AUTHOR ("Zhicheng Tang");
#endif
@@ -108,9 +111,9 @@ MODULE_AUTHOR ("Zhicheng Tang");
/*end of externs */
-#ifndef TI_STATIC_ALLOCATIONS
-#define TI_STATIC_ALLOCATIONS
-#endif
+//#ifndef TI_STATIC_ALLOCATIONS
+//#define TI_STATIC_ALLOCATIONS
+//#endif
#define tn7atm_kfree_skb(x) dev_kfree_skb(x)
@@ -135,7 +138,7 @@ static int EnableQoS = FALSE;
/* prototypes */
static int tn7atm_set_can_support_adsl2 (int can);
-static int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci);
+static int tn7atm_open (struct atm_vcc *vcc);
void tn7atm_close (struct atm_vcc *vcc);
@@ -298,13 +301,12 @@ static const struct atmdev_ops tn7atm_op
getsockopt: NULL,
setsockopt: NULL,
send: tn7atm_send,
- sg_send: NULL,
phy_put: NULL,
phy_get: NULL,
change_qos: tn7atm_change_qos,
};
-const char drv_proc_root_folder[] = "avalanche/";
+const char drv_proc_root_folder[] = "avalanche";
static struct proc_dir_entry *root_proc_dir_entry = NULL;
#define DRV_PROC_MODE 0644
static int proc_root_already_exists = TRUE;
@@ -626,56 +628,6 @@ static int turbodsl_check_priority_type(
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
- * Function: int tn7atm_walk_vccs(struct atm_dev *dev, short *vcc, int *vci)
- *
- * Description: retrieve VPI/VCI for connection
- *
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-static int tn7atm_walk_vccs (struct atm_vcc *vcc, short *vpi, int *vci)
-{
- struct atm_vcc *walk;
-
- /*
- * find a free VPI
- */
- if (*vpi == ATM_VPI_ANY)
- {
-
- for (*vpi = 0, walk = vcc->dev->vccs; walk; walk = walk->next)
- {
-
- if ((walk->vci == *vci) && (walk->vpi == *vpi))
- {
- (*vpi)++;
- walk = vcc->dev->vccs;
- }
- }
- }
-
- /*
- * find a free VCI
- */
- if (*vci == ATM_VCI_ANY)
- {
-
- for (*vci = ATM_NOT_RSV_VCI, walk = vcc->dev->vccs; walk;
- walk = walk->next)
- {
-
- if ((walk->vpi = *vpi) && (walk->vci == *vci))
- {
- *vci = walk->vci + 1;
- walk = vcc->dev->vccs;
- }
- }
- }
-
- return 0;
-}
-
-
-/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *
* Function: int tn7atm_sar_irq(void)
*
* Description: tnetd73xx SAR interrupt.
@@ -766,7 +718,7 @@ static int __init tn7atm_irq_request (st
priv->sar_irq = LNXINTNUM (ATM_SAR_INT); /* Interrupt line # */
- if (request_irq (priv->sar_irq, tn7atm_sar_irq, SA_INTERRUPT, "SAR ", dev))
+ if (request_irq (priv->sar_irq, tn7atm_sar_irq, IRQF_DISABLED, "SAR ", dev))
printk ("Could not register tn7atm_sar_irq\n");
/*
@@ -777,8 +729,8 @@ static int __init tn7atm_irq_request (st
{
def_sar_inter_pace = os_atoi (ptr);
}
- avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
- def_sar_inter_pace);
+ /* avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
+ def_sar_inter_pace); */
#ifdef AR7_EFM
@@ -790,7 +742,7 @@ static int __init tn7atm_irq_request (st
* Reigster Receive interrupt A
*/
priv->dsl_irq = LNXINTNUM (ATM_DSL_INT); /* Interrupt line # */
- if (request_irq (priv->dsl_irq, tn7atm_dsl_irq, SA_INTERRUPT, "DSL ", dev))
+ if (request_irq (priv->dsl_irq, tn7atm_dsl_irq, IRQF_DISABLED, "DSL ", dev))
printk ("Could not register tn7atm_dsl_irq\n");
/***** VRB Tasklet Mode ****/
@@ -958,11 +910,15 @@ static int __init tn7atm_get_ESI (struct
#define ATM_VBR_RT 5
#endif
-int tn7atm_open (struct atm_vcc *vcc, short vpi, int vci)
+int tn7atm_open (struct atm_vcc *vcc)
{
tn7atm_activate_vc_parm_t tn7atm_activate_vc_parm;
int rc;
//int flags;
+ tn7atm_activate_vc_parm.pcr = 0x20000;
+ tn7atm_activate_vc_parm.scr = 0x20000;
+ tn7atm_activate_vc_parm.mbs = 0x20000;
+ tn7atm_activate_vc_parm.cdvt = 10000;
dgprintf(1, "tn7atm_open()\n");
@@ -974,24 +930,18 @@ int tn7atm_open (struct atm_vcc *vcc, sh
return -1;
}
- MOD_INC_USE_COUNT;
+// MOD_INC_USE_COUNT;
- /* find a free VPI/VCI */
- tn7atm_walk_vccs(vcc, &vpi, &vci);
-
- vcc->vpi = vpi;
- vcc->vci = vci;
-
- if ((vci == ATM_VCI_UNSPEC) || (vpi == ATM_VCI_UNSPEC))
+ if ((vcc->vci == ATM_VCI_UNSPEC) || (vcc->vpi == ATM_VCI_UNSPEC))
{
- MOD_DEC_USE_COUNT;
+// MOD_DEC_USE_COUNT;
return -EBUSY;
}
- tn7atm_activate_vc_parm.vpi = vpi;
- tn7atm_activate_vc_parm.vci = vci;
+ tn7atm_activate_vc_parm.vpi = vcc->vpi;
+ tn7atm_activate_vc_parm.vci = vcc->vci;
- if ((vpi == CLEAR_EOC_VPI) && (vci == CLEAR_EOC_VCI))
+ if ((vcc->vpi == CLEAR_EOC_VPI) && (vcc->vci == CLEAR_EOC_VCI))
{
/* always use (max_dma_chan+1) for clear eoc */
tn7atm_activate_vc_parm.chan = EOC_DMA_CHAN;
@@ -999,7 +949,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
/* check to see whether clear eoc is opened or not */
if (tn7atm_activate_vc_parm.priv->lut[tn7atm_activate_vc_parm.chan].inuse)
{
- MOD_DEC_USE_COUNT;
+// MOD_DEC_USE_COUNT;
printk("tn7atm_open: Clear EOC channel (dmachan=%d) already in use.\n", tn7atm_activate_vc_parm.chan);
return -EBUSY;
}
@@ -1008,7 +958,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
if (rc)
{
printk("tn7atm_open: failed to setup clear_eoc\n");
- MOD_DEC_USE_COUNT;
+// MOD_DEC_USE_COUNT;
return -EBUSY;
}
tn7atm_set_lut(tn7atm_activate_vc_parm.priv,vcc, tn7atm_activate_vc_parm.chan);
@@ -1017,17 +967,17 @@ int tn7atm_open (struct atm_vcc *vcc, sh
}
else /* PVC channel setup */
{
- if ((vpi==REMOTE_MGMT_VPI) && (vci==REMOTE_MGMT_VCI))
+ if ((vcc->vpi==REMOTE_MGMT_VPI) && (vcc->vci==REMOTE_MGMT_VCI))
{
tn7atm_activate_vc_parm.chan = 14; /* always use chan 14 for MII PVC-base romote mgmt */
}
else
{
- rc = tn7atm_lut_find(vpi, vci);
+ rc = tn7atm_lut_find(vcc->vpi, vcc->vci);
/* check to see whether PVC is opened or not */
if(ATM_NO_DMA_CHAN != rc)
{
- MOD_DEC_USE_COUNT;
+// MOD_DEC_USE_COUNT;
printk("PVC already opened. dmachan = %d\n", rc);
return -EBUSY;
}
@@ -1059,6 +1009,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
tn7atm_activate_vc_parm.priority = 2;
break;
+#if 0
case ATM_VBR: /* Variable Bit Rate-Non RealTime*/
tn7atm_activate_vc_parm.qos = 1;
tn7atm_activate_vc_parm.priority = 1;
@@ -1080,6 +1031,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
tn7atm_activate_vc_parm.mbs = vcc->qos.txtp.max_pcr;
tn7atm_activate_vc_parm.cdvt = vcc->qos.txtp.max_cdv;
break;
+#endif
default:
tn7atm_activate_vc_parm.qos = 2;
@@ -1107,7 +1059,7 @@ int tn7atm_open (struct atm_vcc *vcc, sh
if (rc < 0)
{
printk("failed to activate hw channel\n");
- MOD_DEC_USE_COUNT;
+// MOD_DEC_USE_COUNT;
tn7atm_lut_clear(vcc, tn7atm_activate_vc_parm.chan);
//spin_unlock_irqrestore(&chan_init_lock, flags);
return -EBUSY;
@@ -1197,7 +1149,7 @@ void tn7atm_close (struct atm_vcc *vcc)
tn7atm_lut_clear (vcc, dmachan);
//spin_unlock_irqrestore (&closeLock, closeFlag);
- MOD_DEC_USE_COUNT;
+// MOD_DEC_USE_COUNT;
dgprintf (1, "Leave tn7atm_close\n");
}
@@ -1630,8 +1582,7 @@ int tn7atm_receive (void *os_dev, int ch
* firewall is on */
dgprintf (3, "pushing the skb...\n");
-
- skb->stamp = vcc->timestamp = xtime;
+ __net_timestamp(skb);
xdump ((unsigned char *) skb->data, skb->len, 5);
@@ -1854,8 +1805,7 @@ printk("!!!free atm irq: tn7atm_exit\n")
kfree (dev->dev_data);
- // atm_dev_deregister (dev);
- shutdown_atm_dev (dev);
+ atm_dev_deregister (dev);
/*
* remove proc entries
@@ -2086,9 +2036,6 @@ static int __init tn7atm_detect (void)
* Set up proc entry for atm stats
*/
- if (tn7atm_xlate_proc_name
- (drv_proc_root_folder, &root_proc_dir_entry, &residual))
- {
printk ("Creating new root folder %s in the proc for the driver stats \n",
drv_proc_root_folder);
root_proc_dir_entry = proc_mkdir (drv_proc_root_folder, NULL);
@@ -2098,7 +2045,6 @@ static int __init tn7atm_detect (void)
return -ENOMEM;
}
proc_root_already_exists = FALSE;
- }
/*
@@ -2731,7 +2677,5 @@ int tn7atm_proc_turbodsl_write(struct fi
return count;
}
-#ifdef MODULE
module_init (tn7atm_detect);
module_exit (tn7atm_exit);
-#endif /* MODULE */
--- a/tn7atm.h
+++ b/tn7atm.h
@@ -20,7 +20,8 @@
//#include "mips_support.h"
#include <linux/list.h>
-#include <linux/config.h>
+#define MIPS_EXCEPTION_OFFSET 8
+#define LNXINTNUM(x)((x) + MIPS_EXCEPTION_OFFSET)
#ifdef CONFIG_MODVERSIONS
#include <linux/modversions.h>
--- a/tn7dsl.c
+++ b/tn7dsl.c
@@ -102,7 +102,6 @@
* UR8_MERGE_END CQ11813
* 09/18/07 CPH CQ11466: Added EFM support.
*********************************************************************************************/
-#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
@@ -110,8 +109,6 @@
#include <linux/delay.h>
#include <linux/spinlock.h>
#include <linux/smp_lock.h>
-#include <asm/io.h>
-#include <asm/mips-boards/prom.h>
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <linux/ctype.h>
@@ -119,6 +116,12 @@
#include <linux/timer.h>
#include <linux/vmalloc.h>
#include <linux/file.h>
+#include <linux/firmware.h>
+
+#include <asm/io.h>
+#include <asm/ar7/ar7.h>
+#include <asm/ar7/prom.h>
+
/* Modules specific header files */
#ifdef AR7_EFM
#include "tn7efm.h"
@@ -185,7 +188,7 @@ led_reg_t ledreg[2];
static struct led_funcs ledreg[2];
#endif
-#define DEV_DSLMOD 1
+#define DEV_DSLMOD CTL_UNNUMBERED
#define MAX_STR_SIZE 256
#define DSL_MOD_SIZE 256
@@ -316,7 +319,7 @@ static PITIDSLHW_T pIhw;
static volatile int bshutdown;
static char info[MAX_STR_SIZE];
/* Used for DSL Polling enable */
-static DECLARE_MUTEX_LOCKED (adsl_sem_overlay);
+static struct semaphore adsl_sem_overlay;
//kthread_t overlay_thread;
/* end of module wide declars */
@@ -369,6 +372,14 @@ int os_atoih (const char *pstr)
return val;
}
+int avalanche_request_intr_pacing(int irq_nr, unsigned int blk_num,
+ unsigned int pace_value)
+{
+ printk("avalanche_request_pacing(%d, %u, %u); // not implemented\n", irq_nr, blk_num, pace_value);
+ return 0;
+}
+
+
int os_atoi(const char *pStr)
{
int MulNeg = (*pStr == '-' ? -1 : 1);
@@ -405,39 +416,6 @@ void dprintf (int uDbgLevel, char *szFmt
#endif
}
-int strcmp(const char *s1, const char *s2)
-{
-
- int size = strlen(s1);
-
- return(strncmp(s1, s2, size));
-}
-
-int strncmp(const char *s1, const char *s2, size_t size)
-{
- int i = 0;
- int max_size = (int)size;
-
- while((s1[i] != 0) && i < max_size)
- {
- if(s2[i] == 0)
- {
- return -1;
- }
- if(s1[i] != s2[i])
- {
- return 1;
- }
- i++;
- }
- if(s2[i] != 0)
- {
- return 1;
- }
-
- return 0;
-}
-
// * UR8_MERGE_START CQ10640 Jack Zhang
int tn7dsl_dump_dsp_memory(char *input_str) //cph99
{
@@ -487,144 +465,78 @@ unsigned int shim_osGetCpuFrequency(void
return CpuFrequency;
}
-int shim_osLoadFWImage(unsigned char *ptr)
+static void avsar_release(struct device *dev)
{
- unsigned int bytesRead;
- mm_segment_t oldfs;
- static struct file *filp;
- unsigned int imageLength=0x5ffff;
-
-#ifdef AR7_EFM
- int dp_alt=0;
- char *ptr1=NULL;
-#ifdef EFM_DEBUG
- char *ptr2=NULL;
- char *ptr3=NULL;
-#endif
-
- if ((ptr1 = prom_getenv("DSL_DP_ALT")) != NULL)
- {
- dp_alt=os_atoi(ptr1);
- if (dp_alt==1)
- {
- filp = filp_open(DSP_DEBUG_FIRMWARE_PATH,00,O_RDONLY);
- if (!IS_ERR(filp))
- {
- strcpy (DSP_FIRMWARE_PATH, DSP_DEBUG_FIRMWARE_PATH);
- }
- }
-#ifdef EFM_DEBUG
- else if (dp_alt==2)
- {
- if ((ptr2 = prom_getenv("DSL_DP")) != NULL)
- {
- if (!strncmp(ptr2, "DSL_DP", 6))
- { // indirect naming
- if ((ptr3 = prom_getenv(ptr2)) != NULL)
- filp = filp_open(ptr3,00,O_RDONLY);
- ptr2 = ptr3; // redirect ptr2 to ptr3
- }
-
- filp = filp_open(ptr2,00,O_RDONLY);
- if (!IS_ERR(filp))
- {
- strcpy (DSP_FIRMWARE_PATH, ptr2);
- }
- }
- }
- printk("dp_path=%s\n", DSP_FIRMWARE_PATH);
-#endif
- }
-#endif
-
- dgprintf(4, "tn7dsl_read_dsp()\n");
-
- dgprintf(4,"open file %s\n", DSP_FIRMWARE_PATH);
-
- filp=filp_open(DSP_FIRMWARE_PATH,00,O_RDONLY);
- if(IS_ERR(filp))
- {
- printk("Failed: Could not open DSP binary file\n");
- return -1;
- }
-
- if (filp->f_dentry != NULL)
- {
- if (filp->f_dentry->d_inode != NULL)
- {
- printk ("DSP binary filesize = %d bytes\n",
- (int) filp->f_dentry->d_inode->i_size);
- imageLength = (unsigned int)filp->f_dentry->d_inode->i_size + 0x200;
- }
- }
-
- if (filp->f_op->read==NULL)
- return -1; /* File(system) doesn't allow reads */
-
- /*
- * Disable parameter checking
- */
- oldfs = get_fs();
- set_fs(KERNEL_DS);
-
- /*
- * Now read bytes from postion "StartPos"
- */
- filp->f_pos = 0;
-
- bytesRead = filp->f_op->read(filp,ptr,imageLength,&filp->f_pos);
-
- dgprintf(4,"file length = %d\n", bytesRead);
-
- set_fs(oldfs);
-
- /*
- * Close the file
- */
- fput(filp);
-
- return bytesRead;
+ printk(KERN_DEBUG "avsar firmware released\n");
}
+static struct device avsar = {
+ .bus_id = "vlynq",
+ .release = avsar_release,
+};
-unsigned int shim_read_overlay_page (void *ptr, unsigned int secOffset,
- unsigned int secLength)
+int shim_osLoadFWImage(unsigned char *ptr)
{
- unsigned int bytesRead;
- mm_segment_t oldfs;
- struct file *filp;
-
- dgprintf(4,"shim_read_overlay_page\n");
- //dgprintf(4,"sec offset=%d, sec length =%d\n", secOffset, secLength);
+ const struct firmware *fw_entry;
+ size_t size;
- filp=filp_open(DSP_FIRMWARE_PATH,00,O_RDONLY);
- if(filp ==NULL)
- {
- printk("Failed: Could not open DSP binary file\n");
- return -1;
- }
-
- if (filp->f_op->read==NULL)
- return -1; /* File(system) doesn't allow reads */
-
- /*
- * Now read bytes from postion "StartPos"
- */
+ printk("requesting firmware image \"ar0700xx.bin\"\n");
+ if(device_register(&avsar) < 0) {
+ printk(KERN_ERR
+ "avsar: device_register fails\n");
+ return -1;
+ }
+
+ if (request_firmware(&fw_entry, "ar0700xx.bin", &avsar)) {
+ printk(KERN_ERR
+ "avsar: Firmware not available\n");
+ device_unregister(&avsar);
+ return -1;
+ }
+ size = fw_entry->size;
+ device_unregister(&avsar);
+ if (size > 0x6ffff) {
+ printk(KERN_ERR
+ "avsar: Firmware too big (%d bytes)\n", size);
+ release_firmware(fw_entry);
+ return -1;
+ }
+ memcpy(ptr, fw_entry->data, size);
+ release_firmware(fw_entry);
+ return size;
+}
+
+unsigned int shim_read_overlay_page(void *ptr, unsigned int secOffset, unsigned int secLength)
+{
+ const struct firmware *fw_entry;
+
+ printk("requesting firmware image \"ar0700xx.bin\"\n");
+ if (device_register(&avsar) < 0) {
+ printk(KERN_ERR
+ "avsar: device_register fails\n");
+ return -1;
+ }
+
+ if (request_firmware(&fw_entry, "ar0700xx.bin", &avsar)) {
+ printk(KERN_ERR
+ "avsar: Firmware not available\n");
+ device_unregister(&avsar);
+ return -1;
+ }
+
+ device_unregister(&avsar);
+ if (fw_entry->size > secLength) {
+ printk(KERN_ERR
+ "avsar: Firmware too big (%d bytes)\n", fw_entry->size);
+ release_firmware(fw_entry);
+ return -1;
+ }
+ memcpy(ptr + secOffset, fw_entry->data, secLength);
+ release_firmware(fw_entry);
+ return secLength;
+}
- if(filp->f_op->llseek)
- filp->f_op->llseek(filp,secOffset, 0);
- oldfs = get_fs();
- set_fs(KERNEL_DS);
- filp->f_pos = secOffset;
- bytesRead = filp->f_op->read(filp,ptr,secLength,&filp->f_pos);
- set_fs(oldfs);
- /*
- * Close the file
- */
- fput(filp);
- return bytesRead;
-}
int shim_osLoadDebugFWImage(unsigned char *ptr)
{
@@ -3287,6 +3199,7 @@ int tn7dsl_init(void *priv)
int high_precision_selected = 0;
// UR8_MERGE_END CQ11054*
+ sema_init(&adsl_sem_overlay, 0);
/*
* start dsl
*/
@@ -3665,7 +3578,7 @@ static int dslmod_sysctl(ctl_table *ctl,
*/
if(write)
{
- ret = proc_dostring(ctl, write, filp, buffer, lenp);
+ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
switch (ctl->ctl_name)
{
@@ -3751,14 +3664,14 @@ static int dslmod_sysctl(ctl_table *ctl,
else
{
len += sprintf(info+len, mod_req);
- ret = proc_dostring(ctl, write, filp, buffer, lenp);
+ ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
}
return ret;
}
ctl_table dslmod_table[] = {
- {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, &dslmod_sysctl}
+ {DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, NULL, &dslmod_sysctl, &sysctl_string}
,
{0}
};
@@ -3781,8 +3694,7 @@ void tn7dsl_dslmod_sysctl_register(void)
if (initialized == 1)
return;
- dslmod_sysctl_header = register_sysctl_table(dslmod_root_table, 1);
- dslmod_root_table->child->de->owner = THIS_MODULE;
+ dslmod_sysctl_header = register_sysctl_table(dslmod_root_table);
/*
* set the defaults
--- a/tn7sar.c
+++ b/tn7sar.c
@@ -43,7 +43,6 @@
* 09/18/07 CPH CQ11466: Added EFM support.
*******************************************************************************/
-#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
@@ -51,12 +50,13 @@
#include <linux/delay.h>
#include <linux/spinlock.h>
#include <linux/smp_lock.h>
-#include <asm/io.h>
-#include <asm/mips-boards/prom.h>
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <linux/ctype.h>
+#include <asm/io.h>
+#include <asm/ar7/ar7.h>
+#include <asm/ar7/prom.h>
#define _CPHAL_AAL5
#define _CPHAL_SAR

View File

@@ -1,37 +0,0 @@
--- a/tn7atm.c
+++ b/tn7atm.c
@@ -633,7 +633,7 @@ static int turbodsl_check_priority_type(
* Description: tnetd73xx SAR interrupt.
*
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-static void tn7atm_sar_irq (int irq, void *voiddev, struct pt_regs *regs)
+static irqreturn_t tn7atm_sar_irq (int irq, void *voiddev)
{
struct atm_dev *atmdev;
Tn7AtmPrivate *priv;
@@ -660,6 +660,7 @@ static void tn7atm_sar_irq (int irq, voi
#ifdef TIATM_INST_SUPP
psp_trace_par (ATM_DRV_SAR_ISR_EXIT, retval);
#endif
+ return IRQ_HANDLED;
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -669,7 +670,7 @@ static void tn7atm_sar_irq (int irq, voi
* Description: tnetd73xx DSL interrupt.
*
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
-static void tn7atm_dsl_irq (int irq, void *voiddev, struct pt_regs *regs)
+static irqreturn_t tn7atm_dsl_irq (int irq, void *voiddev)
{
struct atm_dev *atmdev;
Tn7AtmPrivate *priv;
@@ -691,6 +692,8 @@ static void tn7atm_dsl_irq (int irq, voi
#ifdef TIATM_INST_SUPP
psp_trace_par (ATM_DRV_DSL_ISR_EXIT, retval);
#endif
+
+ return IRQ_HANDLED;
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -1,11 +0,0 @@
--- a/tn7api.h
+++ b/tn7api.h
@@ -118,7 +118,7 @@ int tn7dsl_proc_dbgmsg_write(struct file
int tn7dsl_proc_dbgmsg_read(char* buf, char **start, off_t offset, int count,int *eof, void *data);
#endif
//UR8_MERGE_END CQ11813
-inline int tn7dsl_handle_interrupt(void);
+int tn7dsl_handle_interrupt(void);
void tn7dsl_dslmod_sysctl_register(void);
void tn7dsl_dslmod_sysctl_unregister(void);

View File

@@ -1,44 +0,0 @@
--- a/dsl_hal_advcfg.c
+++ b/dsl_hal_advcfg.c
@@ -36,9 +36,9 @@
* 05Jul05 0.00.09 CPH CQ9775: Change dslhal_advcfg_configDsTones input parameters & support for ADSL2+
* 24Jul05 0.00.10 CPH Fixed comments in dslhal_advcfg_configDsTones function header
*******************************************************************************/
-#include <dev_host_interface.h>
-#include <dsl_hal_register.h>
-#include <dsl_hal_support.h>
+#include "dev_host_interface.h"
+#include "dsl_hal_register.h"
+#include "dsl_hal_support.h"
/*****************************************************************************/
/* ACT API functions -- To be moved into their own independent module --RamP */
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,7 @@
CONFIG_SANGAM_ATM=m
#EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
-EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
+#EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
+EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
obj-$(CONFIG_SANGAM_ATM) := tiatm.o
-tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o
+tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o dsl_hal_advcfg.o
--- a/tn7dsl.c
+++ b/tn7dsl.c
@@ -3053,6 +3053,14 @@ static int tn7dsl_set_dsl(void)
dslhal_api_setRateAdaptFlag(pIhw, os_atoi(ptr));
}
+ // set powercutback
+ ptr = NULL;
+ ptr = prom_getenv("powercutback");
+ if(ptr)
+ {
+ dslhal_advcfg_onOffPcb(pIhw, os_atoi(ptr));
+ }
+
// trellis
ptr = NULL;
ptr = prom_getenv("trellis");

View File

@@ -1,16 +0,0 @@
--- a/tn7sar.c
+++ b/tn7sar.c
@@ -125,10 +125,10 @@ enum
//09/05/07: cph, move to tn7atm.h
// #define RESERVED_OAM_CHANNEL 15
-#define AAL5_PARM "id=aal5, base = 0x03000000, offset = 0, int_line=15, ch0=[RxBufSize=1522; RxNumBuffers = 32; RxServiceMax = 50; TxServiceMax=50; TxNumBuffers=32; CpcsUU=0x5aa5; TxVc_CellRate=0x3000; TxVc_AtmHeader=0x00000640]"
-#define SAR_PARM "id=sar,base = 0x03000000, reset_bit = 9, offset = 0; UniNni = 0, PdspEnable = 1"
+#define CH0_PARM "RxBufSize=1522, RxNumBuffers=32, RxServiceMax=50, TxServiceMax=50, TxNumBuffers=32, CpcsUU=0x5aa5, TxVc_CellRate=0x3000, TxVc_AtmHeader=0x00000640"
+#define AAL5_PARM "id=aal5, base=0x03000000, offset=0, int_line=15, ch0=[" CH0_PARM "]"
+#define SAR_PARM "id=sar, base=0x03000000, reset_bit=9, offset=0; UniNni=0, PdspEnable=1, Debug=0xFFFFFFFF"
#define RESET_PARM "id=ResetControl, base=0xA8611600"
-#define CH0_PARM "RxBufSize=1522, RxNumBuffers = 32, RxServiceMax = 50, TxServiceMax=50, TxNumBuffers=32, CpcsUU=0x5aa5, TxVc_CellRate=0x3000, TxVc_AtmHeader=0x00000640"
#define MAX_PVC_TABLE_ENTRY 16

View File

@@ -1,11 +0,0 @@
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,7 @@
CONFIG_SANGAM_ATM=m
#EXTRA_CFLAGS += -DEL -I. -DPOST_SILICON -DCOMMON_NSP -DCONFIG_LED_MODULE -DDEREGISTER_LED -DNO_ACT
#EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -DNO_ACT -D__NO__VOICE_PATCH__ -DEL
-EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
+#EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL
+EXTRA_CFLAGS += -DEL -I$(PWD) -DPOST_SILICON -DCOMMON_NSP -D__NO__VOICE_PATCH__ -DEL -DCPATM_TASKLET_MODE
obj-$(CONFIG_SANGAM_ATM) := tiatm.o
tiatm-objs += cpsar.o aal5sar.o tn7sar.o tn7atm.o tn7dsl.o dsl_hal_api.o dsl_hal_support.o dsl_hal_advcfg.o

View File

@@ -1,675 +0,0 @@
--- a/tn7atm.c
+++ b/tn7atm.c
@@ -95,6 +95,146 @@
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION ("Tnetd73xx ATM Device Driver");
MODULE_AUTHOR ("Zhicheng Tang");
+
+int mp_sar_ipacemax = -1;
+module_param_named(ipacemax, mp_sar_ipacemax, int, 0);
+MODULE_PARM_DESC(ipacemax, "Interrupt pacing");
+
+char *mp_macc = NULL;
+module_param_named(macc, mp_macc, charp, 0);
+MODULE_PARM_DESC(macc, "MAC address");
+
+int mp_dsp_noboost = -1;
+module_param_named(dsp_noboost, mp_dsp_noboost, int, 0);
+MODULE_PARM_DESC(dsp_noboost, "Suppress DSP frequency boost");
+
+int mp_dsp_freq = -1;
+module_param_named(dsp_freq, mp_dsp_freq, int, 0);
+MODULE_PARM_DESC(dsp_freq, "Frequency to boost the DSP to");
+
+char *mp_featctl0 = NULL;
+module_param_named(featctl0, mp_featctl0, charp, 0);
+MODULE_PARM_DESC(featctl0, "DSL feature control 0");
+
+char *mp_featctl1 = NULL;
+module_param_named(featctl1, mp_featctl1, charp, 0);
+MODULE_PARM_DESC(featctl1, "DSL feature control 1");
+
+char *mp_phyctl0 = NULL;
+module_param_named(phyctl0, mp_phyctl0, charp, 0);
+MODULE_PARM_DESC(phyctl0, "DSL PHY control 0");
+
+char *mp_phyctl1 = NULL;
+module_param_named(phyctl1, mp_phyctl1, charp, 0);
+MODULE_PARM_DESC(phyctl1, "DSL PHY control 1");
+
+int mp_turbodsl = -1;
+module_param_named(turbodsl, mp_turbodsl, int, 0);
+MODULE_PARM_DESC(turbodsl, "Enable TurboDSL");
+
+int mp_sar_rxbuf = -1;
+module_param_named(sar_rxbuf, mp_sar_rxbuf, int, 0);
+MODULE_PARM_DESC(sar_rxbuf, "SAR RxBuf size");
+
+int mp_sar_rxmax = -1;
+module_param_named(sar_rxmax, mp_sar_rxmax, int, 0);
+MODULE_PARM_DESC(sar_rxmax, "SAR RxMax size");
+
+int mp_sar_txbuf = -1;
+module_param_named(sar_txbuf, mp_sar_txbuf, int, 0);
+MODULE_PARM_DESC(sar_txbuf, "SAR TxBuf size");
+
+int mp_sar_txmax = -1;
+module_param_named(sar_txmax, mp_sar_txmax, int, 0);
+MODULE_PARM_DESC(sar_txmax, "SAR TxMax size");
+
+char *mp_modulation = NULL;
+module_param_named(modulation, mp_modulation, charp, 0);
+MODULE_PARM_DESC(modulation, "Modulation");
+
+int mp_fine_gain_control = -1;
+module_param_named(fine_gain_control, mp_fine_gain_control, int, 0);
+MODULE_PARM_DESC(fine_gain_control, "Fine gain control");
+
+int mp_fine_gain_value = -1;
+module_param_named(fine_gain_value, mp_fine_gain_value, int, 0);
+MODULE_PARM_DESC(fine_gain_value, "Fine gain value");
+
+int mp_enable_margin_retrain = -1;
+module_param_named(enable_margin_retrain, mp_enable_margin_retrain, int, 0);
+MODULE_PARM_DESC(enable_margin_retrain, "Enable margin retrain");
+
+int mp_margin_threshold = -1;
+module_param_named(margin_threshold, mp_margin_threshold, int, 0);
+MODULE_PARM_DESC(margin_threshold, "Margin retrain treshold");
+
+int mp_enable_rate_adapt = -1;
+module_param_named(enable_rate_adapt, mp_enable_rate_adapt, int, 0);
+MODULE_PARM_DESC(enable_rate_adapt, "Enable rate adaption");
+
+int mp_powercutback = -1;
+module_param_named(powercutback, mp_powercutback, int, 0);
+MODULE_PARM_DESC(powercutback, "Enable / disable powercutback");
+
+int mp_trellis = -1;
+module_param_named(trellis, mp_trellis, int, 0);
+MODULE_PARM_DESC(trellis, "Enable / disable trellis coding");
+
+int mp_bitswap = -1;
+module_param_named(bitswap, mp_bitswap, int, 0);
+MODULE_PARM_DESC(bitswap, "Enable / disable bitswap");
+
+int mp_maximum_bits_per_carrier = -1;
+module_param_named(maximum_bits_per_carrier, mp_maximum_bits_per_carrier, int, 0);
+MODULE_PARM_DESC(maximum_bits_per_carrier, "Maximum bits per carrier");
+
+int mp_maximum_interleave_depth = -1;
+module_param_named(maximum_interleave_depth, mp_maximum_interleave_depth, int, 0);
+MODULE_PARM_DESC(maximum_interleave_depth, "Maximum interleave depth");
+
+int mp_pair_selection = -1;
+module_param_named(pair_selection, mp_pair_selection, int, 0);
+MODULE_PARM_DESC(pair_selection, "Pair selection");
+
+int mp_dgas_polarity = -1;
+module_param_named(dgas_polarity, mp_dgas_polarity, int, 0);
+MODULE_PARM_DESC(dgas_polarity, "DGAS polarity");
+
+int mp_los_alarm = -1;
+module_param_named(los_alarm, mp_los_alarm, int, 0);
+MODULE_PARM_DESC(los_alarm, "LOS alarm");
+
+char *mp_eoc_vendor_id = NULL;
+module_param_named(eoc_vendor_id, mp_eoc_vendor_id, charp, 0);
+MODULE_PARM_DESC(eoc_vendor_id, "EOC vendor id");
+
+int mp_eoc_vendor_revision = -1;
+module_param_named(eoc_vendor_revision, mp_eoc_vendor_revision, int, 0);
+MODULE_PARM_DESC(eoc_vendor_revision, "EOC vendor revision");
+
+char *mp_eoc_vendor_serialnum = NULL;
+module_param_named(eoc_vendor_serialnum, mp_eoc_vendor_serialnum, charp, 0);
+MODULE_PARM_DESC(eoc_vendor_serialnum, "EOC vendor serial number");
+
+char *mp_invntry_vernum = NULL;
+module_param_named(invntry_vernum, mp_invntry_vernum, charp, 0);
+MODULE_PARM_DESC(invntry_vernum, "Inventory revision number");
+
+int mp_dsl_bit_tmode = -1;
+module_param_named(dsl_bit_tmode, mp_dsl_bit_tmode, int, 0);
+MODULE_PARM_DESC(dsl_bit_tmode, "DSL bit training mode");
+
+int mp_high_precision = -1;
+module_param_named(high_precision, mp_high_precision, int, 0);
+MODULE_PARM_DESC(high_precision, "High precision");
+
+int mp_autopvc_enable = -1;
+module_param_named(autopvc_enable, mp_autopvc_enable, int, 0);
+MODULE_PARM_DESC(autopvc_enable, "Enable / disable automatic PVC");
+
+int mp_oam_lb_timeout = -1;
+module_param_named(oam_lb_timeout, mp_oam_lb_timeout, int, 0);
+MODULE_PARM_DESC(oam_lb_timeout, "OAM LB timeout");
#endif
#ifndef TRUE
@@ -728,9 +868,9 @@
* interrupt pacing
*/
ptr = prom_getenv ("sar_ipacemax");
- if (ptr)
+ if (ptr || mp_sar_ipacemax != -1)
{
- def_sar_inter_pace = os_atoi (ptr);
+ def_sar_inter_pace = mp_sar_ipacemax == -1 ? os_atoi (ptr) : mp_sar_ipacemax;
}
/* avalanche_request_pacing (priv->sar_irq, ATM_SAR_INT_PACING_BLOCK_NUM,
def_sar_inter_pace); */
@@ -878,9 +1018,18 @@
{
int i;
char esi_addr[ESI_LEN] = { 0x00, 0x00, 0x11, 0x22, 0x33, 0x44 };
- char *esiaddr_str = NULL;
+ char *esiaddr_str = mp_macc;
- esiaddr_str = prom_getenv ("macc");
+ if (esiaddr_str == NULL)
+ esiaddr_str = prom_getenv ("macdsl");
+ if (esiaddr_str == NULL)
+ esiaddr_str = prom_getenv ("macc");
+ if (esiaddr_str == NULL)
+ esiaddr_str = prom_getenv ("HWA_1");
+ if (esiaddr_str == NULL)
+ esiaddr_str = prom_getenv ("macb");
+ if (esiaddr_str == NULL)
+ esiaddr_str = prom_getenv ("maca");
if (!esiaddr_str)
{
@@ -2139,15 +2288,15 @@
//UR8_MERGE_END CQ10450*
cp = prom_getenv ("dsp_noboost");
- if (cp)
+ if (cp || mp_dsp_noboost != -1)
{
- dsp_noboost = os_atoi (cp);
+ dsp_noboost = mp_dsp_noboost == -1 ? os_atoi (cp) : mp_dsp_noboost;
}
cp = (char *) prom_getenv ("dsp_freq");
- if (cp)
+ if (cp || mp_dsp_freq != -1)
{
- dspfreq = os_atoi (cp);
+ dspfreq = mp_dsp_freq == -1 ? os_atoi (cp) : mp_dsp_freq;
if (dspfreq == 250)
{
boostDsp = 1;
@@ -2396,15 +2545,17 @@
// Inter-Op DSL phy Control
// Note the setting of _dsl_Feature_0 and _dsl_Feature_1 must before
// dslhal_api_dslStartup (in tn7dsl_init()).
- if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_0")) != NULL)
+ if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_0")) != NULL || mp_featctl0 != NULL)
{
- _dsl_Feature_0 = os_atoih (ptr);
+ if (mp_featctl0 != NULL) ptr = mp_featctl0;
+ _dsl_Feature_0 = os_atoh (ptr);
_dsl_Feature_0_defined = 1;
}
- if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_1")) != NULL)
+ if ((ptr = prom_getenv ("DSL_FEATURE_CNTL_1")) != NULL || mp_featctl1 != NULL)
{
- _dsl_Feature_1 = os_atoih (ptr);
+ if (mp_featctl1 != NULL) ptr = mp_featctl1;
+ _dsl_Feature_1 = os_atoh (ptr);
_dsl_Feature_1_defined = 1;
}
@@ -2412,15 +2563,17 @@
// DSL phy Feature Control
// Note the setting of _dsl_PhyControl_0 and _dsl_PhyControl_1 must before
// dslhal_api_dslStartup (in tn7dsl_init()).
- if ((ptr = prom_getenv ("DSL_PHY_CNTL_0")) != NULL)
+ if ((ptr = prom_getenv ("DSL_PHY_CNTL_0")) != NULL || mp_phyctl0 != NULL)
{
- _dsl_PhyControl_0 = os_atoih (ptr);
+ if (mp_phyctl0 != NULL) ptr = mp_phyctl0;
+ _dsl_PhyControl_0 = os_atoh (ptr);
_dsl_PhyControl_0_defined = 1;
}
- if ((ptr = prom_getenv ("DSL_PHY_CNTL_1")) != NULL)
+ if ((ptr = prom_getenv ("DSL_PHY_CNTL_1")) != NULL || mp_phyctl1 != NULL)
{
- _dsl_PhyControl_1 = os_atoih (ptr);
+ if (mp_phyctl1 != NULL) ptr = mp_phyctl1;
+ _dsl_PhyControl_1 = os_atoh (ptr);
_dsl_PhyControl_1_defined = 1;
}
@@ -2440,12 +2593,12 @@
// read config for turbo dsl
ptr = prom_getenv ("TurboDSL");
- if (ptr)
+ if (ptr || mp_turbodsl != -1)
{
#if 1 //[KT]
bTurboDsl = os_atoi (ptr);
#else
- priv->bTurboDsl = os_atoi (ptr);
+ priv->bTurboDsl = mp_turbodsl == -1 ? os_atoi (ptr) : mp_turbodsl;
#endif
}
else
@@ -2459,33 +2612,33 @@
priv->sarRxBuf = RX_BUFFER_NUM;
ptr = NULL;
ptr = prom_getenv ("SarRxBuf");
- if (ptr)
+ if (ptr || mp_sar_rxbuf != -1)
{
- priv->sarRxBuf = os_atoi (ptr);
+ priv->sarRxBuf = mp_sar_rxbuf == -1 ? os_atoi (ptr) : mp_sar_rxbuf;
}
priv->sarRxMax = RX_SERVICE_MAX;
ptr = NULL;
ptr = prom_getenv ("SarRxMax");
- if (ptr)
+ if (ptr || mp_sar_rxmax != -1)
{
- priv->sarRxMax = os_atoi (ptr);
+ priv->sarRxMax = mp_sar_rxmax == -1 ? os_atoi (ptr) : mp_sar_rxmax;
}
priv->sarTxBuf = TX_BUFFER_NUM;
ptr = NULL;
ptr = prom_getenv ("SarTxBuf");
- if (ptr)
+ if (ptr || mp_sar_txbuf != -1)
{
- priv->sarTxBuf = os_atoi (ptr);
+ priv->sarTxBuf = mp_sar_txbuf == -1 ? os_atoi (ptr) : mp_sar_txbuf;
}
priv->sarTxMax = TX_SERVICE_MAX;
ptr = NULL;
ptr = prom_getenv ("SarTxMax");
- if (ptr)
+ if (ptr || mp_sar_txmax != -1)
{
- priv->sarTxMax = os_atoi (ptr);
+ priv->sarTxMax = mp_sar_txmax == -1 ? os_atoi (ptr) : mp_sar_txmax;
}
#ifdef AR7_EFM
--- a/tn7dsl.c
+++ b/tn7dsl.c
@@ -148,6 +148,27 @@
#define NEW_TRAINING_VAL_T1413 128
#define NEW_TRAINING_VAL_MMODE 255
+extern char *mp_modulation;
+extern int mp_fine_gain_control;
+extern int mp_fine_gain_value;
+extern int mp_enable_margin_retrain;
+extern int mp_margin_threshold;
+extern int mp_enable_rate_adapt;
+extern int mp_powercutback;
+extern int mp_trellis;
+extern int mp_bitswap;
+extern int mp_maximum_bits_per_carrier;
+extern int mp_maximum_interleave_depth;
+extern int mp_pair_selection;
+extern int mp_dgas_polarity;
+extern int mp_los_alarm;
+extern char *mp_eoc_vendor_id;
+extern int mp_eoc_vendor_revision;
+extern char *mp_eoc_vendor_serialnum;
+extern char *mp_invntry_vernum;
+extern int mp_dsl_bit_tmode;
+extern int mp_high_precision;
+
int testflag1 = 0;
extern int __guDbgLevel;
extern sar_stat_t sarStat;
@@ -2933,24 +2954,24 @@ static int tn7dsl_set_dsl(void)
(unsigned char *) &oamFeature, 4);
ptr = prom_getenv("DSL_FEATURE_CNTL_0");
- if(!ptr)
- prom_setenv("DSL_FEATURE_CNTL_0", "0x00004000");
+ //if(!ptr)
+ //prom_setenv("DSL_FEATURE_CNTL_0", "0x00004000");
ptr = prom_getenv("DSL_FEATURE_CNTL_1");
- if(!ptr)
- prom_setenv("DSL_FEATURE_CNTL_1", "0x00000000");
+ //if(!ptr)
+ //prom_setenv("DSL_FEATURE_CNTL_1", "0x00000000");
ptr = prom_getenv("DSL_PHY_CNTL_0");
- if(!ptr)
- prom_setenv("DSL_PHY_CNTL_0", "0x00000400");
+ //if(!ptr)
+ //prom_setenv("DSL_PHY_CNTL_0", "0x00000400");
ptr = prom_getenv("enable_margin_retrain");
- if(!ptr)
- prom_setenv("enable_margin_retrain", "0");
+ //if(!ptr)
+ //prom_setenv("enable_margin_retrain", "0");
ptr = prom_getenv("modulation");
- if(!ptr)
- prom_setenv("modulation", "0xbf");
+ //if(!ptr)
+ //prom_setenv("modulation", "0xbf");
#define EOC_VENDOR_ID "4200534153000000"
#define EOC_VENDOR_REVISION "FW370090708b1_55"
@@ -2959,25 +2980,25 @@ static int tn7dsl_set_dsl(void)
ptr = prom_getenv("eoc_vendor_id");
if(!ptr || strcmp(ptr,EOC_VENDOR_ID) != 0 || strlen(ptr) != strlen(EOC_VENDOR_ID))
{
- if(ptr)
- prom_unsetenv("eoc_vendor_id");
- prom_setenv("eoc_vendor_id",EOC_VENDOR_ID);
+ //if(ptr)
+ //prom_unsetenv("eoc_vendor_id");
+ //prom_setenv("eoc_vendor_id",EOC_VENDOR_ID);
}
ptr = prom_getenv("eoc_vendor_revision");
if(!ptr || strcmp(ptr,EOC_VENDOR_REVISION) != 0 || strlen(ptr) != strlen(EOC_VENDOR_REVISION))
{
- if(ptr)
- prom_unsetenv("eoc_vendor_revision");
- prom_setenv("eoc_vendor_revision",EOC_VENDOR_REVISION);
+ //if(ptr)
+ //prom_unsetenv("eoc_vendor_revision");
+ //prom_setenv("eoc_vendor_revision",EOC_VENDOR_REVISION);
}
ptr = prom_getenv("eoc_vendor_serialnum");
if(!ptr || strcmp(ptr,EOC_VENDOR_SERIALNUM) != 0 || strlen(ptr) != strlen(EOC_VENDOR_SERIALNUM))
{
- if(ptr)
- prom_unsetenv("eoc_vendor_serialnum");
- prom_setenv("eoc_vendor_serialnum",EOC_VENDOR_SERIALNUM);
+ //if(ptr)
+ // prom_unsetenv("eoc_vendor_serialnum");
+ //prom_setenv("eoc_vendor_serialnum",EOC_VENDOR_SERIALNUM);
}
/* Do only if we are in the new Base PSP 7.4.*/
@@ -2994,92 +3015,88 @@ static int tn7dsl_set_dsl(void)
we clear the modulation environment variable, as this could potentially
not have the same meaning in the new mode.
*/
- prom_unsetenv("modulation");
- prom_setenv("DSL_UPG_DONE", "1");
+ //prom_unsetenv("modulation");
+ //prom_setenv("DSL_UPG_DONE", "1");
}
}
#endif
// modulation
ptr = prom_getenv("modulation");
- if (ptr)
+ if (ptr || mp_modulation != NULL)
{
- tn7dsl_set_modulation(ptr, FALSE);
+ tn7dsl_set_modulation(mp_modulation == NULL ? ptr : mp_modulation, FALSE);
}
// Fine Gains
ptr = prom_getenv("fine_gain_control");
- if (ptr)
+ if (ptr || mp_fine_gain_control != -1)
{
- value = os_atoi(ptr);
+ value = mp_fine_gain_control == -1 ? os_atoi(ptr) : mp_fine_gain_control;
tn7dsl_ctrl_fineGain(value);
}
ptr = NULL;
ptr = prom_getenv("fine_gain_value");
- if(ptr)
- tn7dsl_set_fineGainValue(os_atoh(ptr));
+ if(ptr || mp_fine_gain_value != -1)
+ tn7dsl_set_fineGainValue(mp_fine_gain_value == -1 ? os_atoh(ptr) : mp_fine_gain_value);
// margin retrain
ptr = NULL;
ptr = prom_getenv("enable_margin_retrain");
- if(ptr)
+ value = mp_enable_margin_retrain == -1 ? (ptr ? os_atoi(ptr) : 0) : mp_enable_margin_retrain;
+
+ if (value == 1)
{
- value = os_atoi(ptr);
- if(value == 1)
+ dslhal_api_setMarginMonitorFlags(pIhw, 0, 1);
+ bMarginRetrainEnable = 1;
+ //printk("enable showtime margin monitor.\n");
+
+ ptr = NULL;
+ ptr = prom_getenv("margin_threshold");
+ value = mp_margin_threshold == -1 ? (ptr ? os_atoi(ptr) : 0) : mp_margin_threshold;
+
+ if(value >= 0)
{
- dslhal_api_setMarginMonitorFlags(pIhw, 0, 1);
- bMarginRetrainEnable = 1;
- //printk("enable showtime margin monitor.\n");
- ptr = NULL;
- ptr = prom_getenv("margin_threshold");
- if(ptr)
- {
- value = os_atoi(ptr);
- //printk("Set margin threshold to %d x 0.5 db\n",value);
- if(value >= 0)
- {
- dslhal_api_setMarginThreshold(pIhw, value);
- bMarginThConfig=1;
- }
- }
+ dslhal_api_setMarginThreshold(pIhw, value);
+ bMarginThConfig=1;
}
}
// rate adapt
ptr = NULL;
ptr = prom_getenv("enable_rate_adapt");
- if(ptr)
+ if(ptr || mp_enable_rate_adapt != -1)
{
- dslhal_api_setRateAdaptFlag(pIhw, os_atoi(ptr));
+ dslhal_api_setRateAdaptFlag(pIhw, mp_enable_rate_adapt == -1 ? os_atoi(ptr) : mp_enable_rate_adapt);
}
// set powercutback
ptr = NULL;
ptr = prom_getenv("powercutback");
- if(ptr)
+ if(ptr || mp_powercutback != -1)
{
- dslhal_advcfg_onOffPcb(pIhw, os_atoi(ptr));
+ dslhal_advcfg_onOffPcb(pIhw, mp_powercutback == -1 ? os_atoi(ptr) : mp_powercutback);
}
// trellis
ptr = NULL;
ptr = prom_getenv("trellis");
- if(ptr)
+ if(ptr || mp_trellis != -1)
{
- dslhal_api_setTrellisFlag(pIhw, os_atoi(ptr));
- trellis = os_atoi(ptr);
+ trellis = mp_trellis == -1 ? os_atoi(ptr) : mp_trellis;
+ dslhal_api_setTrellisFlag(pIhw, trellis);
//printk("trellis=%d\n");
}
// bitswap
ptr = NULL;
ptr = prom_getenv("bitswap");
- if(ptr)
+ if(ptr || mp_bitswap != -1)
{
int offset[2] = {33, 0};
unsigned int bitswap;
- bitswap = os_atoi(ptr);
+ bitswap = mp_bitswap == -1 ? os_atoi(ptr) : mp_bitswap;
tn7dsl_generic_read(2, offset);
dslReg &= dslhal_support_byteSwap32(0xFFFFFF00);
@@ -3097,46 +3114,47 @@ static int tn7dsl_set_dsl(void)
// maximum bits per carrier
ptr = NULL;
ptr = prom_getenv("maximum_bits_per_carrier");
- if(ptr)
+ if(ptr || mp_maximum_bits_per_carrier != -1)
{
- dslhal_api_setMaxBitsPerCarrierUpstream(pIhw, os_atoi(ptr));
+ dslhal_api_setMaxBitsPerCarrierUpstream(pIhw, mp_maximum_bits_per_carrier == -1 ? os_atoi(ptr) : mp_maximum_bits_per_carrier);
}
// maximum interleave depth
ptr = NULL;
ptr = prom_getenv("maximum_interleave_depth");
- if(ptr)
+ if(ptr || mp_maximum_interleave_depth != -1)
{
- dslhal_api_setMaxInterleaverDepth(pIhw, os_atoi(ptr));
+ dslhal_api_setMaxInterleaverDepth(pIhw, mp_maximum_interleave_depth == -1 ? os_atoi(ptr) : mp_maximum_interleave_depth);
}
// inner and outer pairs
ptr = NULL;
ptr = prom_getenv("pair_selection");
- if(ptr)
+ if(ptr || mp_pair_selection != -1)
{
- dslhal_api_selectInnerOuterPair(pIhw, os_atoi(ptr));
+ dslhal_api_selectInnerOuterPair(pIhw, mp_pair_selection == -1 ? os_atoi(ptr) : mp_pair_selection);
}
ptr = NULL;
ptr = prom_getenv("dgas_polarity");
- if(ptr)
+ if(ptr || mp_dgas_polarity != -1)
{
dslhal_api_configureDgaspLpr(pIhw, 1, 1);
- dslhal_api_configureDgaspLpr(pIhw, 0, os_atoi(ptr));
+ dslhal_api_configureDgaspLpr(pIhw, 0, mp_dgas_polarity == -1 ? os_atoi(ptr) : mp_dgas_polarity);
}
ptr = NULL;
ptr = prom_getenv("los_alarm");
- if(ptr)
+ if(ptr || mp_los_alarm != -1)
{
- dslhal_api_disableLosAlarm(pIhw, os_atoi(ptr));
+ dslhal_api_disableLosAlarm(pIhw, mp_los_alarm == -1 ? os_atoi(ptr) : mp_los_alarm);
}
ptr = NULL;
ptr = prom_getenv("eoc_vendor_id");
- if(ptr)
+ if(ptr || mp_eoc_vendor_id != NULL)
{
+ ptr = mp_eoc_vendor_id == NULL ? ptr : mp_eoc_vendor_id;
for(i=0;i<8;i++)
{
tmp[0]=ptr[i*2];
@@ -3161,26 +3179,26 @@ static int tn7dsl_set_dsl(void)
}
ptr = NULL;
ptr = prom_getenv("eoc_vendor_revision");
- if(ptr)
+ if(ptr || mp_eoc_vendor_revision != -1)
{
- value = os_atoi(ptr);
+ value = mp_eoc_vendor_revision == -1 ? os_atoi(ptr) : mp_eoc_vendor_revision;
//printk("eoc rev=%d\n", os_atoi(ptr));
dslhal_api_setEocRevisionNumber(pIhw, (char *)&value);
}
ptr = NULL;
ptr = prom_getenv("eoc_vendor_serialnum");
- if(ptr)
+ if(ptr || mp_eoc_vendor_serialnum != NULL)
{
- dslhal_api_setEocSerialNumber(pIhw, ptr);
+ dslhal_api_setEocSerialNumber(pIhw, mp_eoc_vendor_serialnum == NULL ? ptr : mp_eoc_vendor_serialnum);
}
// CQ10037 Added invntry_vernum environment variable to be able to set version number in ADSL2, ADSL2+ modes.
ptr = NULL;
ptr = prom_getenv("invntry_vernum");
- if(ptr)
+ if(ptr || mp_invntry_vernum != NULL)
{
- dslhal_api_setEocRevisionNumber(pIhw, ptr);
+ dslhal_api_setEocRevisionNumber(pIhw, mp_invntry_vernum == NULL ? ptr : mp_invntry_vernum);
}
return 0;
@@ -3225,7 +3243,7 @@ int tn7dsl_init(void *priv)
* backward compatibility.
*/
cp = prom_getenv("DSL_BIT_TMODE");
- if (cp)
+ if (cp || mp_dsl_bit_tmode != -1)
{
printk("%s : env var DSL_BIT_TMODE is set\n", __FUNCTION__);
/*
@@ -3254,9 +3272,9 @@ int tn7dsl_init(void *priv)
// UR8_MERGE_START CQ11054 Jack Zhang
cp = prom_getenv("high_precision");
- if (cp)
+ if (cp || mp_high_precision != -1)
{
- high_precision_selected = os_atoi(cp);
+ high_precision_selected = mp_high_precision == -1 ? os_atoi(cp) : mp_high_precision;
}
if ( high_precision_selected)
{
--- a/tn7sar.c
+++ b/tn7sar.c
@@ -76,6 +76,8 @@ typedef void OS_SETUP;
#include "tn7atm.h"
#include "tn7api.h"
+extern int mp_oam_lb_timeout;
+extern int mp_autopvc_enable;
/* PDSP Firmware files */
#include "tnetd7300_sar_firm.h"
@@ -932,9 +934,9 @@ int tn7sar_setup_oam_channel(Tn7AtmPriva
pHalDev = (HAL_DEVICE *)priv->pSarHalDev;
pauto_pvc = prom_getenv("autopvc_enable");
- if(pauto_pvc) //CQ10273
+ if(pauto_pvc || mp_autopvc_enable != -1) //CQ10273
{
- auto_pvc =tn7sar_strtoul(pauto_pvc, NULL, 10);
+ auto_pvc = mp_autopvc_enable == -1 ? tn7sar_strtoul(pauto_pvc, NULL, 10) : mp_autopvc_enable;
}
memset(&chInfo, 0xff, sizeof(chInfo));
@@ -1133,9 +1135,9 @@ int tn7sar_init(struct atm_dev *dev, Tn7
/* read in oam lb timeout value */
pLbTimeout = prom_getenv("oam_lb_timeout");
- if(pLbTimeout)
+ if(pLbTimeout || mp_oam_lb_timeout != -1)
{
- lbTimeout =tn7sar_strtoul(pLbTimeout, NULL, 10);
+ lbTimeout = mp_oam_lb_timeout == -1 ? tn7sar_strtoul(pLbTimeout, NULL, 10) : mp_oam_lb_timeout;
oamLbTimeout = lbTimeout;
pHalFunc->Control(pHalDev,"OamLbTimeout", "Set", &lbTimeout);
}

View File

@@ -1,30 +0,0 @@
--- a/tn7dsl.c
+++ b/tn7dsl.c
@@ -117,6 +117,7 @@
#include <linux/vmalloc.h>
#include <linux/file.h>
#include <linux/firmware.h>
+#include <linux/version.h>
#include <asm/io.h>
#include <asm/ar7/ar7.h>
@@ -492,7 +493,9 @@ static void avsar_release(struct device
}
static struct device avsar = {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
.bus_id = "vlynq",
+#endif
.release = avsar_release,
};
@@ -501,6 +504,9 @@ int shim_osLoadFWImage(unsigned char *pt
const struct firmware *fw_entry;
size_t size;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
+ dev_set_name(&avsar, "avsar");
+#endif
printk("requesting firmware image \"ar0700xx.bin\"\n");
if(device_register(&avsar) < 0) {
printk(KERN_ERR

View File

@@ -1,54 +0,0 @@
--- a/tn7atm.c
+++ b/tn7atm.c
@@ -76,10 +76,16 @@
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <linux/ctype.h>
+#include <linux/version.h>
#include <asm/io.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
#include <asm/ar7/ar7.h>
#include <asm/ar7/prom.h>
+#else
+#include <asm/mach-ar7/ar7.h>
+#include <asm/mach-ar7/prom.h>
+#endif
#include "dsl_hal_api.h"
#ifdef AR7_EFM
--- a/tn7dsl.c
+++ b/tn7dsl.c
@@ -120,8 +120,13 @@
#include <linux/version.h>
#include <asm/io.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
#include <asm/ar7/ar7.h>
#include <asm/ar7/prom.h>
+#else
+#include <asm/mach-ar7/ar7.h>
+#include <asm/mach-ar7/prom.h>
+#endif
/* Modules specific header files */
#ifdef AR7_EFM
--- a/tn7sar.c
+++ b/tn7sar.c
@@ -53,10 +53,16 @@
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <linux/ctype.h>
+#include <linux/version.h>
#include <asm/io.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
#include <asm/ar7/ar7.h>
#include <asm/ar7/prom.h>
+#else
+#include <asm/mach-ar7/ar7.h>
+#include <asm/mach-ar7/prom.h>
+#endif
#define _CPHAL_AAL5
#define _CPHAL_SAR

View File

@@ -1,79 +0,0 @@
--- a/tn7dsl.c
+++ b/tn7dsl.c
@@ -215,7 +215,11 @@ led_reg_t ledreg[2];
static struct led_funcs ledreg[2];
#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
#define DEV_DSLMOD CTL_UNNUMBERED
+#else
+#define DEV_DSLMOD 0
+#endif
#define MAX_STR_SIZE 256
#define DSL_MOD_SIZE 256
@@ -3615,9 +3619,16 @@ static int dslmod_sysctl(ctl_table *ctl,
*/
if(write)
{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
-
+#else
+ ret = proc_dostring(ctl, write, buffer, lenp, 0);
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
switch (ctl->ctl_name)
+#else
+ switch ((long)ctl->extra2)
+#endif
{
case DEV_DSLMOD:
ptr = strpbrk(info, " \t");
@@ -3701,14 +3712,29 @@ static int dslmod_sysctl(ctl_table *ctl,
else
{
len += sprintf(info+len, mod_req);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
ret = proc_dostring(ctl, write, filp, buffer, lenp, 0);
+#else
+ ret = proc_dostring(ctl, write, buffer, lenp, 0);
+#endif
}
return ret;
}
ctl_table dslmod_table[] = {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
{DEV_DSLMOD, "dslmod", info, DSL_MOD_SIZE, 0644, NULL, NULL, &dslmod_sysctl, &sysctl_string}
+#else
+ {
+ .procname = "dslmod",
+ .data = info,
+ .maxlen = DSL_MOD_SIZE,
+ .mode = 0644,
+ .proc_handler = &dslmod_sysctl,
+ .extra2 = (void *)DEV_DSLMOD,
+ }
+#endif
,
{0}
};
@@ -3716,7 +3742,16 @@ ctl_table dslmod_table[] = {
/* Make sure that /proc/sys/dev is there */
ctl_table dslmod_root_table[] = {
#ifdef CONFIG_PROC_FS
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
{CTL_DEV, "dev", NULL, 0, 0555, dslmod_table}
+ #else
+ {
+ .procname = "dev",
+ .maxlen = 0,
+ .mode = 0555,
+ .child = dslmod_table,
+ }
+ #endif
,
#endif /* CONFIG_PROC_FS */
{0}

View File

@@ -1,36 +0,0 @@
--- a/tn7atm.c
+++ b/tn7atm.c
@@ -2000,7 +2000,11 @@ static int __init tn7atm_register (Tn7At
dgprintf (4, "device %s being registered\n", priv->name);
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
mydev = atm_dev_register (priv->proc_name, &tn7atm_ops, -1, NULL);
+ #else
+ mydev = atm_dev_register (priv->proc_name, NULL, &tn7atm_ops, -1, NULL);
+ #endif
if (mydev == NULL)
{
--- a/tn7dsl.c
+++ b/tn7dsl.c
@@ -512,14 +512,17 @@ int shim_osLoadFWImage(unsigned char *pt
{
const struct firmware *fw_entry;
size_t size;
+ int ret;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
dev_set_name(&avsar, "avsar");
#endif
printk("requesting firmware image \"ar0700xx.bin\"\n");
- if(device_register(&avsar) < 0) {
+ dev_set_name(&avsar, "avsar");
+ ret = device_register(&avsar);
+ if (ret < 0) {
printk(KERN_ERR
- "avsar: device_register fails\n");
+ "avsar: device_register fails, error%i\n", ret);
return -1;
}

View File

@@ -1,33 +0,0 @@
--- a/tn7atm.c
+++ b/tn7atm.c
@@ -72,7 +72,7 @@
#include <linux/atmdev.h>
#include <linux/delay.h>
#include <linux/spinlock.h>
-#include <linux/smp_lock.h>
+#include <linux/interrupt.h>
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <linux/ctype.h>
--- a/tn7sar.c
+++ b/tn7sar.c
@@ -49,7 +49,7 @@
#include <linux/atmdev.h>
#include <linux/delay.h>
#include <linux/spinlock.h>
-#include <linux/smp_lock.h>
+#include <linux/interrupt.h>
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <linux/ctype.h>
--- a/tn7dsl.c
+++ b/tn7dsl.c
@@ -108,7 +108,7 @@
#include <linux/atmdev.h>
#include <linux/delay.h>
#include <linux/spinlock.h>
-#include <linux/smp_lock.h>
+#include <linux/interrupt.h>
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <linux/ctype.h>

View File

@@ -1,40 +0,0 @@
#
# Copyright (C) 2008 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)/kernel.mk
PKG_NAME:=avila-wdt
PKG_RELEASE:=1
include $(INCLUDE_DIR)/package.mk
define KernelPackage/avila-wdt
SUBMENU:=Other modules
TITLE:=GPIO hardware watchdog driver for modified Avila boards
DEPENDS:=@GPIO_SUPPORT @TARGET_ixp4xx
FILES:=$(PKG_BUILD_DIR)/avila-wdt.ko
AUTOLOAD:=$(call AutoLoad,10,avila-wdt)
endef
MAKE_OPTS:= \
ARCH="$(LINUX_KARCH)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
SUBDIRS="$(PKG_BUILD_DIR)"
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Build/Compile
$(MAKE) -C "$(LINUX_DIR)" \
$(MAKE_OPTS) \
modules
endef
$(eval $(call KernelPackage,avila-wdt))

View File

@@ -1 +0,0 @@
obj-m := avila-wdt.o

View File

@@ -1,231 +0,0 @@
/*
* avila-wdt.c
* Copyright (C) 2009 Felix Fietkau <nbd@openwrt.org>
*
* based on:
* drivers/char/watchdog/ixp4xx_wdt.c
*
* Watchdog driver for Intel IXP4xx network processors
*
* Author: Deepak Saxena <dsaxena@plexity.net>
*
* Copyright 2004 (c) MontaVista, Software, Inc.
* Based on sa1100 driver, Copyright (C) 2000 Oleg Drokin <green@crimea.edu>
*
* This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*/
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/jiffies.h>
#include <linux/timer.h>
#include <linux/fs.h>
#include <linux/miscdevice.h>
#include <linux/watchdog.h>
#include <linux/init.h>
#include <linux/bitops.h>
#include <linux/uaccess.h>
#include <mach/hardware.h>
static int nowayout = WATCHDOG_NOWAYOUT;
static int heartbeat = 20; /* (secs) Default is 20 seconds */
static unsigned long wdt_status;
static atomic_t wdt_counter;
struct timer_list wdt_timer;
#define WDT_IN_USE 0
#define WDT_OK_TO_CLOSE 1
#define WDT_RUNNING 2
static void wdt_refresh(unsigned long data)
{
if (test_bit(WDT_RUNNING, &wdt_status)) {
if (atomic_dec_and_test(&wdt_counter)) {
printk(KERN_WARNING "Avila watchdog expired, expect a reboot soon!\n");
clear_bit(WDT_RUNNING, &wdt_status);
return;
}
}
/* strobe to the watchdog */
gpio_line_set(14, IXP4XX_GPIO_HIGH);
gpio_line_set(14, IXP4XX_GPIO_LOW);
mod_timer(&wdt_timer, jiffies + msecs_to_jiffies(500));
}
static void wdt_enable(void)
{
atomic_set(&wdt_counter, heartbeat * 2);
/* Disable clock generator output on GPIO 14/15 */
*IXP4XX_GPIO_GPCLKR &= ~(1 << 8);
/* activate GPIO 14 out */
gpio_line_config(14, IXP4XX_GPIO_OUT);
gpio_line_set(14, IXP4XX_GPIO_LOW);
if (!test_bit(WDT_RUNNING, &wdt_status))
wdt_refresh(0);
set_bit(WDT_RUNNING, &wdt_status);
}
static void wdt_disable(void)
{
/* Re-enable clock generator output on GPIO 14/15 */
*IXP4XX_GPIO_GPCLKR |= (1 << 8);
}
static int avila_wdt_open(struct inode *inode, struct file *file)
{
if (test_and_set_bit(WDT_IN_USE, &wdt_status))
return -EBUSY;
clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
wdt_enable();
return nonseekable_open(inode, file);
}
static ssize_t
avila_wdt_write(struct file *file, const char *data, size_t len, loff_t *ppos)
{
if (len) {
if (!nowayout) {
size_t i;
clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
for (i = 0; i != len; i++) {
char c;
if (get_user(c, data + i))
return -EFAULT;
if (c == 'V')
set_bit(WDT_OK_TO_CLOSE, &wdt_status);
}
}
wdt_enable();
}
return len;
}
static struct watchdog_info ident = {
.options = WDIOF_CARDRESET | WDIOF_MAGICCLOSE |
WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
.identity = "Avila Watchdog",
};
static long avila_wdt_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
int ret = -ENOTTY;
int time;
switch (cmd) {
case WDIOC_GETSUPPORT:
ret = copy_to_user((struct watchdog_info *)arg, &ident,
sizeof(ident)) ? -EFAULT : 0;
break;
case WDIOC_GETSTATUS:
ret = put_user(0, (int *)arg);
break;
case WDIOC_KEEPALIVE:
wdt_enable();
ret = 0;
break;
case WDIOC_SETTIMEOUT:
ret = get_user(time, (int *)arg);
if (ret)
break;
if (time <= 0 || time > 60) {
ret = -EINVAL;
break;
}
heartbeat = time;
wdt_enable();
/* Fall through */
case WDIOC_GETTIMEOUT:
ret = put_user(heartbeat, (int *)arg);
break;
}
return ret;
}
static int avila_wdt_release(struct inode *inode, struct file *file)
{
if (test_bit(WDT_OK_TO_CLOSE, &wdt_status))
wdt_disable();
else
printk(KERN_CRIT "WATCHDOG: Device closed unexpectedly - "
"timer will not stop\n");
clear_bit(WDT_IN_USE, &wdt_status);
clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
return 0;
}
static const struct file_operations avila_wdt_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.write = avila_wdt_write,
.unlocked_ioctl = avila_wdt_ioctl,
.open = avila_wdt_open,
.release = avila_wdt_release,
};
static struct miscdevice avila_wdt_miscdev = {
.minor = WATCHDOG_MINOR + 1,
.name = "avila_watchdog",
.fops = &avila_wdt_fops,
};
static int __init avila_wdt_init(void)
{
int ret;
init_timer(&wdt_timer);
wdt_timer.expires = 0;
wdt_timer.data = 0;
wdt_timer.function = wdt_refresh;
ret = misc_register(&avila_wdt_miscdev);
if (ret == 0)
printk(KERN_INFO "Avila Watchdog Timer: heartbeat %d sec\n",
heartbeat);
return ret;
}
static void __exit avila_wdt_exit(void)
{
misc_deregister(&avila_wdt_miscdev);
del_timer(&wdt_timer);
wdt_disable();
}
module_init(avila_wdt_init);
module_exit(avila_wdt_exit);
MODULE_AUTHOR("Felix Fietkau <nbd@openwrt.org>");
MODULE_DESCRIPTION("Gateworks Avila Hardware Watchdog");
module_param(heartbeat, int, 0);
MODULE_PARM_DESC(heartbeat, "Watchdog heartbeat in seconds (default 20s)");
module_param(nowayout, int, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");
MODULE_LICENSE("GPL");
MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);

View File

@@ -1,44 +0,0 @@
#
# Copyright (C) 2012 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)/kernel.mk
PKG_NAME:=brcm2708-gpu-fw
PKG_REV:=d5b05be2147bf5dc0137798837af24b0bbbe398d
PKG_VERSION:=20130517
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_REV).tar.gz
PKG_SOURCE_URL:=https://github.com/Hexxeh/rpi-firmware/archive/
PKG_MD5SUM:=9b0ce0a530e237f4c6fe43a36ccf57c3
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/rpi-firmware-$(PKG_REV)
include $(INCLUDE_DIR)/package.mk
define Package/brcm2708-gpu-fw
SECTION:=boot
CATEGORY:=Boot Loaders
DEPENDS:=@TARGET_brcm2708
TITLE:=brcm2708-gpu-fw
DEFAULT:=y if (TARGET_brcm2708)
endef
define Package/brcm2708-gpu-fw/description
GPU and kernel boot firmware for brcm2708.
endef
define Build/Compile
endef
define Build/InstallDev
$(INSTALL_DIR) $(BUILD_DIR)/brcm2708-gpu-fw-boot
$(CP) $(PKG_BUILD_DIR)/* $(BUILD_DIR)/brcm2708-gpu-fw-boot
endef
$(eval $(call BuildPackage,brcm2708-gpu-fw))

View File

@@ -1,53 +0,0 @@
#
# Copyright (C) 2008-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)/kernel.mk
PKG_NAME:=button-hotplug
PKG_RELEASE:=3
include $(INCLUDE_DIR)/package.mk
define KernelPackage/button-hotplug
SUBMENU:=Other modules
TITLE:=Button Hotplug driver
FILES:=$(PKG_BUILD_DIR)/button-hotplug.ko
AUTOLOAD:=$(call AutoLoad,30,button-hotplug,1)
KCONFIG:=
endef
define KernelPackage/button-hotplug/description
Kernel module to generate button hotplug events
endef
EXTRA_KCONFIG:= \
CONFIG_BUTTON_HOTPLUG=m
EXTRA_CFLAGS:= \
$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \
MAKE_OPTS:= \
ARCH="$(LINUX_KARCH)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
SUBDIRS="$(PKG_BUILD_DIR)" \
EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
$(EXTRA_KCONFIG)
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Build/Compile
$(MAKE) -C "$(LINUX_DIR)" \
$(MAKE_OPTS) \
modules
endef
$(eval $(call KernelPackage,button-hotplug))

View File

@@ -1,2 +0,0 @@
config BUTTON_HOTPLUG
tristate "Button Hotplug driver"

View File

@@ -1 +0,0 @@
obj-${CONFIG_BUTTON_HOTPLUG} += button-hotplug.o

View File

@@ -1,349 +0,0 @@
/*
* Button Hotplug driver
*
* Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
*
* Based on the diag.c - GPIO interface driver for Broadcom boards
* Copyright (C) 2006 Mike Baker <mbm@openwrt.org>,
* Copyright (C) 2006-2007 Felix Fietkau <nbd@openwrt.org>
* Copyright (C) 2008 Andy Boyett <agb@openwrt.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/version.h>
#include <linux/kmod.h>
#include <linux/input.h>
#include <linux/workqueue.h>
#include <linux/skbuff.h>
#include <linux/netlink.h>
#include <linux/kobject.h>
#define DRV_NAME "button-hotplug"
#define DRV_VERSION "0.4.1"
#define DRV_DESC "Button Hotplug driver"
#define BH_SKB_SIZE 2048
#define PFX DRV_NAME ": "
#undef BH_DEBUG
#ifdef BH_DEBUG
#define BH_DBG(fmt, args...) printk(KERN_DEBUG "%s: " fmt, DRV_NAME, ##args )
#else
#define BH_DBG(fmt, args...) do {} while (0)
#endif
#define BH_ERR(fmt, args...) printk(KERN_ERR "%s: " fmt, DRV_NAME, ##args )
#ifndef BIT_MASK
#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
#endif
struct bh_priv {
unsigned long *seen;
struct input_handle handle;
};
struct bh_event {
const char *name;
char *action;
unsigned long seen;
struct sk_buff *skb;
struct work_struct work;
};
struct bh_map {
unsigned int code;
const char *name;
};
extern u64 uevent_next_seqnum(void);
#define BH_MAP(_code, _name) \
{ \
.code = (_code), \
.name = (_name), \
}
static struct bh_map button_map[] = {
BH_MAP(BTN_0, "BTN_0"),
BH_MAP(BTN_1, "BTN_1"),
BH_MAP(BTN_2, "BTN_2"),
BH_MAP(BTN_3, "BTN_3"),
BH_MAP(BTN_4, "BTN_4"),
BH_MAP(BTN_5, "BTN_5"),
BH_MAP(BTN_6, "BTN_6"),
BH_MAP(BTN_7, "BTN_7"),
BH_MAP(BTN_8, "BTN_8"),
BH_MAP(BTN_9, "BTN_9"),
BH_MAP(KEY_RESTART, "reset"),
#ifdef KEY_WPS_BUTTON
BH_MAP(KEY_WPS_BUTTON, "wps"),
#endif /* KEY_WPS_BUTTON */
};
/* -------------------------------------------------------------------------*/
static int bh_event_add_var(struct bh_event *event, int argv,
const char *format, ...)
{
static char buf[128];
char *s;
va_list args;
int len;
if (argv)
return 0;
va_start(args, format);
len = vsnprintf(buf, sizeof(buf), format, args);
va_end(args);
if (len >= sizeof(buf)) {
BH_ERR("buffer size too small\n");
WARN_ON(1);
return -ENOMEM;
}
s = skb_put(event->skb, len + 1);
strcpy(s, buf);
BH_DBG("added variable '%s'\n", s);
return 0;
}
static int button_hotplug_fill_event(struct bh_event *event)
{
int ret;
ret = bh_event_add_var(event, 0, "HOME=%s", "/");
if (ret)
return ret;
ret = bh_event_add_var(event, 0, "PATH=%s",
"/sbin:/bin:/usr/sbin:/usr/bin");
if (ret)
return ret;
ret = bh_event_add_var(event, 0, "SUBSYSTEM=%s", "button");
if (ret)
return ret;
ret = bh_event_add_var(event, 0, "ACTION=%s", event->action);
if (ret)
return ret;
ret = bh_event_add_var(event, 0, "BUTTON=%s", event->name);
if (ret)
return ret;
ret = bh_event_add_var(event, 0, "SEEN=%ld", event->seen);
if (ret)
return ret;
ret = bh_event_add_var(event, 0, "SEQNUM=%llu", uevent_next_seqnum());
return ret;
}
static void button_hotplug_work(struct work_struct *work)
{
struct bh_event *event = container_of(work, struct bh_event, work);
int ret = 0;
event->skb = alloc_skb(BH_SKB_SIZE, GFP_KERNEL);
if (!event->skb)
goto out_free_event;
ret = bh_event_add_var(event, 0, "%s@", event->action);
if (ret)
goto out_free_skb;
ret = button_hotplug_fill_event(event);
if (ret)
goto out_free_skb;
NETLINK_CB(event->skb).dst_group = 1;
broadcast_uevent(event->skb, 0, 1, GFP_KERNEL);
out_free_skb:
if (ret) {
BH_ERR("work error %d\n", ret);
kfree_skb(event->skb);
}
out_free_event:
kfree(event);
}
static int button_hotplug_create_event(const char *name, unsigned long seen,
int pressed)
{
struct bh_event *event;
BH_DBG("create event, name=%s, seen=%lu, pressed=%d\n",
name, seen, pressed);
event = kzalloc(sizeof(*event), GFP_KERNEL);
if (!event)
return -ENOMEM;
event->name = name;
event->seen = seen;
event->action = pressed ? "pressed" : "released";
INIT_WORK(&event->work, (void *)(void *)button_hotplug_work);
schedule_work(&event->work);
return 0;
}
/* -------------------------------------------------------------------------*/
#ifdef CONFIG_HOTPLUG
static int button_get_index(unsigned int code)
{
int i;
for (i = 0; i < ARRAY_SIZE(button_map); i++)
if (button_map[i].code == code)
return i;
return -1;
}
static void button_hotplug_event(struct input_handle *handle,
unsigned int type, unsigned int code, int value)
{
struct bh_priv *priv = handle->private;
unsigned long seen = jiffies;
int btn;
BH_DBG("event type=%u, code=%u, value=%d\n", type, code, value);
if (type != EV_KEY)
return;
btn = button_get_index(code);
if (btn < 0)
return;
button_hotplug_create_event(button_map[btn].name,
(seen - priv->seen[btn]) / HZ, value);
priv->seen[btn] = seen;
}
#else
static void button_hotplug_event(struct input_handle *handle,
unsigned int type, unsigned int code, int value)
{
}
#endif /* CONFIG_HOTPLUG */
static int button_hotplug_connect(struct input_handler *handler,
struct input_dev *dev, const struct input_device_id *id)
{
struct bh_priv *priv;
int ret;
int i;
for (i = 0; i < ARRAY_SIZE(button_map); i++)
if (test_bit(button_map[i].code, dev->keybit))
break;
if (i == ARRAY_SIZE(button_map))
return -ENODEV;
priv = kzalloc(sizeof(*priv) +
(sizeof(unsigned long) * ARRAY_SIZE(button_map)),
GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->seen = (unsigned long *) &priv[1];
priv->handle.private = priv;
priv->handle.dev = dev;
priv->handle.handler = handler;
priv->handle.name = DRV_NAME;
ret = input_register_handle(&priv->handle);
if (ret)
goto err_free_priv;
ret = input_open_device(&priv->handle);
if (ret)
goto err_unregister_handle;
BH_DBG("connected to %s\n", dev->name);
return 0;
err_unregister_handle:
input_unregister_handle(&priv->handle);
err_free_priv:
kfree(priv);
return ret;
}
static void button_hotplug_disconnect(struct input_handle *handle)
{
struct bh_priv *priv = handle->private;
input_close_device(handle);
input_unregister_handle(handle);
kfree(priv);
}
static const struct input_device_id button_hotplug_ids[] = {
{
.flags = INPUT_DEVICE_ID_MATCH_EVBIT,
.evbit = { BIT_MASK(EV_KEY) },
},
{
/* Terminating entry */
},
};
MODULE_DEVICE_TABLE(input, button_hotplug_ids);
static struct input_handler button_hotplug_handler = {
.event = button_hotplug_event,
.connect = button_hotplug_connect,
.disconnect = button_hotplug_disconnect,
.name = DRV_NAME,
.id_table = button_hotplug_ids,
};
/* -------------------------------------------------------------------------*/
static int __init button_hotplug_init(void)
{
int ret;
printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
ret = input_register_handler(&button_hotplug_handler);
if (ret)
BH_ERR("unable to register input handler\n");
return ret;
}
module_init(button_hotplug_init);
static void __exit button_hotplug_exit(void)
{
input_unregister_handler(&button_hotplug_handler);
}
module_exit(button_hotplug_exit);
MODULE_DESCRIPTION(DRV_DESC);
MODULE_VERSION(DRV_VERSION);
MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
MODULE_LICENSE("GPL v2");

View File

@@ -1,92 +0,0 @@
#
# Copyright (C) 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)/kernel.mk
PKG_NAME:=ep80579-drivers
PKG_VERSION:=1.0.34
PKG_RELEASE:=1
PKG_SOURCE:=Embedded.L.1.0.34.ADI.R100.tar.gz
PKG_SOURCE_URL:=ftp://ftp.adiengineering.com/Archive/OcracokeIsland/Drivers/Linux/1.0.34/
PKG_MD5SUM:=61df9778f8c1f919257d2f48a0bcb000
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
define KernelPackage/ep80579-drivers/Default
DEPENDS:=@TARGET_x86_ep80579
endef
define KernelPackage/ep80579-eth
$(call KernelPackage/ep80579-drivers/Default)
SUBMENU:=Network Devices
TITLE:=Intel EP80579 ethernet driver
FILES:= \
$(PKG_BUILD_DIR)/Embedded/src/GbE/gcu.ko \
$(PKG_BUILD_DIR)/Embedded/src/GbE/iegbe.ko
AUTOLOAD:=$(call AutoLoad,40,gcu iegbe)
endef
define KernelPackage/ep80579-misc
$(call KernelPackage/ep80579-drivers/Default)
SUBMENU:=Other modules
TITLE:=Misc. Intel EP80579 drivers (DMA,, gpio)
FILES:= \
$(PKG_BUILD_DIR)/Embedded/src/EDMA/dma.ko \
$(PKG_BUILD_DIR)/Embedded/src/GPIO/gpio.ko
AUTOLOAD:=$(call AutoLoad,40,gpio dma)
endef
define KernelPackage/ep80579-can
$(call KernelPackage/ep80579-drivers/Default)
SUBMENU:=Other modules
TITLE:=Intel EP80579 CAN driver
FILES:= \
$(PKG_BUILD_DIR)/Embedded/src/1588/timesync.ko \
$(PKG_BUILD_DIR)/Embedded/src/CAN/can.ko
AUTOLOAD:=$(call AutoLoad,40,timesync can)
endef
define Build/Prepare
rm -rf $(PKG_BUILD_DIR)
mkdir -p $(PKG_BUILD_DIR)
tar xzvf $(DL_DIR)/$(PKG_SOURCE) -C $(PKG_BUILD_DIR)/
$(Build/Patch)
endef
define Build/Compile/Subdir
$(MAKE) -C "$(LINUX_DIR)" \
KSRC="$(LINUX_DIR)" \
KOBJ="$(LINUX_DIR)" \
ENV_DIR=$(PKG_BUILD_DIR)/Embedded \
SUBDIRS="$(PKG_BUILD_DIR)/Embedded/src/$(1)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
ARCHIVER="$(TARGET_CROSS)ar" \
COMPILER="$(TARGET_CC)" \
LINKER="$(TARGET_CROSS)ld" \
ARCH="$(LINUX_KARCH)"
endef
define Build/Compile
$(call Build/Compile/Subdir,GbE)
$(call Build/Compile/Subdir,CAN)
$(call Build/Compile/Subdir,EDMA)
$(call Build/Compile/Subdir,GPIO)
$(call Build/Compile/Subdir,WDT)
$(call Build/Compile/Subdir,1588)
endef
define KernelPackage/ep80579-eth/install
endef
$(eval $(call KernelPackage,ep80579-can))
$(eval $(call KernelPackage,ep80579-eth))
$(eval $(call KernelPackage,ep80579-misc))

File diff suppressed because it is too large Load Diff

View File

@@ -1,22 +0,0 @@
--- a/build_system/build_files/common.mk
+++ b/build_system/build_files/common.mk
@@ -122,7 +122,7 @@ CC=$(COMPILER)
LD=$(LINKER)
AR=$(ARCHIVER)
-CFLAGS+=-O2
+#CFLAGS+=-O2
PWD= $(shell pwd)
--- a/build_system/build_files/OS/linux_2.6.mk
+++ b/build_system/build_files/OS/linux_2.6.mk
@@ -80,7 +80,7 @@ endif
ifeq ($(OS_LEVEL), kernel_space)
-CFLAGS+=
+#CFLAGS+=
endif

View File

@@ -1,53 +0,0 @@
--- a/Embedded/src/1588/1588.c
+++ b/Embedded/src/1588/1588.c
@@ -291,7 +291,7 @@ int pci_probe(struct pci_dev *dev, const
}
- if ( request_irq(dev->irq, &timesync_isr, SA_SHIRQ, DRIVERNAME,
+ if ( request_irq(dev->irq, &timesync_isr, IRQF_SHARED, DRIVERNAME,
&g_drvr_data) )
{
printk("%s-pci_probe: irq\n", DRIVERNAME);
--- a/Embedded/src/CAN/can_main.c
+++ b/Embedded/src/CAN/can_main.c
@@ -424,7 +424,7 @@ int can_open(struct inode *inode, struct
err = request_irq(
can_os->irq,
can_irq_handler,
- SA_SHIRQ,
+ IRQF_SHARED,
iminor(can_os->inode) ? CAN_PROC_1 : CAN_PROC_0,
&(g_can_os[iminor(can_os->inode)])
);
--- a/Embedded/src/EDMA/dma_linux.c
+++ b/Embedded/src/EDMA/dma_linux.c
@@ -367,7 +367,7 @@ int32_t edma_resume(struct pci_dev *dev)
return -ENODEV;
}
- if (request_irq(dev->irq, &edma_irq_handler, SA_SHIRQ,
+ if (request_irq(dev->irq, &edma_irq_handler, IRQF_SHARED,
g_char_drvr_name, dev) )
{
@@ -829,7 +829,7 @@ int32_t edma_probe(struct pci_dev * dev,
/*
* Obtain a (shared) Interrupt Request (IRQ) Line from the OS.
*/
- if (request_irq(dev->irq, &edma_irq_handler, SA_SHIRQ,
+ if (request_irq(dev->irq, &edma_irq_handler, IRQF_SHARED,
g_char_drvr_name, dev) )
{
--- a/Embedded/src/WDT/iwdt.c
+++ b/Embedded/src/WDT/iwdt.c
@@ -1461,7 +1461,7 @@ static int __init wdt_init_one(struct pc
/* Request irq only if wdt_irq is other than 0 */
if (wdt_irq) {
- if (request_irq(wdt_irq, wdt_isr, SA_INTERRUPT | SA_SHIRQ,
+ if (request_irq(wdt_irq, wdt_isr, IRQF_DISABLED | IRQF_SHARED,
"iwdt", &wdt_miscdev)) {
printk("IRQ %d is not free.\n", wdt_irq);
return -EIO;

View File

@@ -1,56 +0,0 @@
--- a/Embedded/src/GbE/iegbe_main.c
+++ b/Embedded/src/GbE/iegbe_main.c
@@ -724,6 +724,26 @@ static void iegbe_dump_eeprom(struct ieg
kfree(data);
}
+static const struct net_device_ops iegbe_netdev_ops = {
+ .ndo_open = iegbe_open,
+ .ndo_stop = iegbe_close,
+ .ndo_start_xmit = iegbe_xmit_frame,
+ .ndo_get_stats = iegbe_get_stats,
+ .ndo_set_rx_mode = iegbe_set_rx_mode,
+ .ndo_set_mac_address = iegbe_set_mac,
+ .ndo_tx_timeout = iegbe_tx_timeout,
+ .ndo_change_mtu = iegbe_change_mtu,
+ .ndo_do_ioctl = iegbe_ioctl,
+ .ndo_validate_addr = eth_validate_addr,
+
+ .ndo_vlan_rx_register = iegbe_vlan_rx_register,
+ .ndo_vlan_rx_add_vid = iegbe_vlan_rx_add_vid,
+ .ndo_vlan_rx_kill_vid = iegbe_vlan_rx_kill_vid,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .ndo_poll_controller = iegbe_netpoll,
+#endif
+};
+
/**
* iegbe_probe - Device Initialization Routine
* @pdev: PCI device information struct
@@ -800,24 +820,11 @@ static int __devinit iegbe_probe(struct
if (!hw->hw_addr)
goto err_ioremap;
- netdev->open = &iegbe_open;
- netdev->stop = &iegbe_close;
- netdev->hard_start_xmit = &iegbe_xmit_frame;
- netdev->get_stats = &iegbe_get_stats;
- netdev->set_rx_mode = &iegbe_set_rx_mode;
- netdev->set_mac_address = &iegbe_set_mac;
- netdev->change_mtu = &iegbe_change_mtu;
- netdev->do_ioctl = &iegbe_ioctl;
+ netdev->netdev_ops = &iegbe_netdev_ops;
set_ethtool_ops(netdev);
- netdev->tx_timeout = &iegbe_tx_timeout;
netdev->watchdog_timeo = 5 * HZ;
netif_napi_add(netdev, &adapter->napi, iegbe_clean, 64);
- netdev->vlan_rx_register = iegbe_vlan_rx_register;
- netdev->vlan_rx_add_vid = iegbe_vlan_rx_add_vid;
- netdev->vlan_rx_kill_vid = iegbe_vlan_rx_kill_vid;
-#ifdef CONFIG_NET_POLL_CONTROLLER
- netdev->poll_controller = iegbe_netpoll;
-#endif
+
strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);

View File

@@ -1,41 +0,0 @@
--- a/Embedded/src/GbE/iegbe_main.c
+++ b/Embedded/src/GbE/iegbe_main.c
@@ -3465,12 +3465,12 @@ static irqreturn_t iegbe_intr_msi(int ir
printk("Critical error! ICR = 0x%x\n", icr);
return IRQ_HANDLED;
}
- if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) {
+ if (likely(napi_schedule_prep(&adapter->napi))) {
adapter->total_tx_bytes = 0;
adapter->total_tx_packets = 0;
adapter->total_rx_bytes = 0;
adapter->total_rx_packets = 0;
- __netif_rx_schedule(netdev, &adapter->napi);
+ __napi_schedule(&adapter->napi);
} else
iegbe_irq_enable(adapter);
@@ -3527,12 +3527,12 @@ iegbe_intr(int irq, void *data)
E1000_WRITE_REG(&adapter->hw, IMC, ~0);
E1000_WRITE_FLUSH(&adapter->hw);
}
- if (likely(netif_rx_schedule_prep(netdev, &adapter->napi))) {
+ if (likely(napi_schedule_prep(&adapter->napi))) {
adapter->total_tx_bytes = 0;
adapter->total_tx_packets = 0;
adapter->total_rx_bytes = 0;
adapter->total_rx_packets = 0;
- __netif_rx_schedule(netdev, &adapter->napi);
+ __napi_schedule(&adapter->napi);
} else
/* this really should not happen! if it does it is basically a
* bug, but not a hard error, so enable ints and continue */
@@ -3574,7 +3574,7 @@ static int iegbe_clean(struct napi_struc
if (work_done < budget) {
if (likely(adapter->itr_setting & 3))
iegbe_set_itr(adapter);
- netif_rx_complete(poll_dev, napi);
+ napi_complete(napi);
iegbe_irq_enable(adapter);
}

View File

@@ -1,103 +0,0 @@
--- a/Embedded/src/GbE/iegbe.h
+++ b/Embedded/src/GbE/iegbe.h
@@ -316,7 +316,6 @@ struct iegbe_adapter {
int cleaned_count);
struct iegbe_rx_ring *rx_ring; /* One per active queue */
struct napi_struct napi;
- struct net_device *polling_netdev; /* One per active queue */
int num_tx_queues;
int num_rx_queues;
--- a/Embedded/src/GbE/iegbe_main.c
+++ b/Embedded/src/GbE/iegbe_main.c
@@ -763,7 +763,7 @@ static int __devinit iegbe_probe(struct
struct iegbe_hw *hw;
static int cards_found = 0;
- int i, err, pci_using_dac;
+ int err, pci_using_dac;
u16 eeprom_data = 0;
u16 eeprom_apme_mask = E1000_EEPROM_APME;
int bars;
@@ -984,11 +984,8 @@ err_eeprom:
iegbe_phy_hw_reset(hw);
if (hw->flash_address)
iounmap(hw->flash_address);
- for (i = 0; i < adapter->num_rx_queues; i++)
- dev_put(&adapter->polling_netdev[i]);
kfree(adapter->tx_ring);
kfree(adapter->rx_ring);
- kfree(adapter->polling_netdev);
err_sw_init:
iounmap(hw->hw_addr);
err_ioremap:
@@ -1017,7 +1014,6 @@ iegbe_remove(struct pci_dev *pdev)
struct net_device *netdev = pci_get_drvdata(pdev);
struct iegbe_adapter *adapter = netdev_priv(netdev);
uint32_t manc;
- int i;
if(adapter->hw.mac_type >= iegbe_82540
&& adapter->hw.mac_type != iegbe_icp_xxxx
@@ -1030,15 +1026,11 @@ iegbe_remove(struct pci_dev *pdev)
}
unregister_netdev(netdev);
- for (i = 0x0; i < adapter->num_rx_queues; i++)
- dev_put(&adapter->polling_netdev[i]);
-
if(!iegbe_check_phy_reset_block(&adapter->hw)) {
iegbe_phy_hw_reset(&adapter->hw);
}
kfree(adapter->tx_ring);
kfree(adapter->rx_ring);
- kfree(adapter->polling_netdev);
iounmap(adapter->hw.hw_addr);
pci_release_regions(pdev);
@@ -1061,7 +1053,6 @@ iegbe_sw_init(struct iegbe_adapter *adap
struct iegbe_hw *hw = &adapter->hw;
struct net_device *netdev = adapter->netdev;
struct pci_dev *pdev = adapter->pdev;
- int i;
/* PCI config space info */
@@ -1111,11 +1102,6 @@ iegbe_sw_init(struct iegbe_adapter *adap
return -ENOMEM;
}
- for (i = 0; i < adapter->num_rx_queues; i++) {
- adapter->polling_netdev[i].priv = adapter;
- dev_hold(&adapter->polling_netdev[i]);
- set_bit(__LINK_STATE_START, &adapter->polling_netdev[i].state);
- }
spin_lock_init(&adapter->tx_queue_lock);
/*
@@ -1137,8 +1123,7 @@ iegbe_sw_init(struct iegbe_adapter *adap
* @adapter: board private structure to initialize
*
* We allocate one ring per queue at run-time since we don't know the
- * number of queues at compile-time. The polling_netdev array is
- * intended for Multiqueue, but should work fine with a single queue.
+ * number of queues at compile-time.
**/
static int __devinit
@@ -1158,15 +1143,6 @@ iegbe_alloc_queues(struct iegbe_adapter
return -ENOMEM;
}
- adapter->polling_netdev = kcalloc(adapter->num_rx_queues,
- sizeof(struct net_device),
- GFP_KERNEL);
- if (!adapter->polling_netdev) {
- kfree(adapter->tx_ring);
- kfree(adapter->rx_ring);
- return -ENOMEM;
- }
-
return E1000_SUCCESS;
}

View File

@@ -1,60 +0,0 @@
--- a/Embedded/src/GbE/iegbe_main.c
+++ b/Embedded/src/GbE/iegbe_main.c
@@ -2161,7 +2161,8 @@ static void iegbe_set_rx_mode(struct net
{
struct iegbe_adapter *adapter = netdev_priv(netdev);
struct iegbe_hw *hw = &adapter->hw;
- struct dev_addr_list *uc_ptr;
+ struct netdev_hw_addr *ha;
+ bool use_uc = false;
struct dev_addr_list *mc_ptr;
u32 rctl;
u32 hash_value;
@@ -2187,12 +2188,11 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
}
}
- uc_ptr = NULL;
if (netdev->uc_count > rar_entries - 1) {
rctl |= E1000_RCTL_UPE;
} else if (!(netdev->flags & IFF_PROMISC)) {
rctl &= ~E1000_RCTL_UPE;
- uc_ptr = netdev->uc_list;
+ use_uc = true;
}
E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
@@ -2210,13 +2210,20 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
* if there are not 14 addresses, go ahead and clear the filters
* -- with 82571 controllers only 0-13 entries are filled here
*/
+ i = 1;
+ if (use_uc)
+ list_for_each_entry(ha, &netdev->uc_list, list) {
+ if (i == rar_entries)
+ break;
+ iegbe_rar_set(hw, ha->addr, i++);
+ }
+
+ WARN_ON(i == rar_entries);
+
mc_ptr = netdev->mc_list;
- for (i = 1; i < rar_entries; i++) {
- if (uc_ptr) {
- iegbe_rar_set(hw, uc_ptr->da_addr, i);
- uc_ptr = uc_ptr->next;
- } else if (mc_ptr) {
+ for (; i < rar_entries; i++) {
+ if (mc_ptr) {
iegbe_rar_set(hw, mc_ptr->da_addr, i);
mc_ptr = mc_ptr->next;
} else {
@@ -2226,7 +2233,6 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
E1000_WRITE_FLUSH(&adapter->hw);
}
}
- WARN_ON(uc_ptr != NULL);
/* clear the old settings from the multicast hash table */

View File

@@ -1,20 +0,0 @@
--- a/Embedded/src/GbE/iegbe_main.c
+++ b/Embedded/src/GbE/iegbe_main.c
@@ -2188,7 +2188,7 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
}
}
- if (netdev->uc_count > rar_entries - 1) {
+ if (netdev->uc.count > rar_entries - 1) {
rctl |= E1000_RCTL_UPE;
} else if (!(netdev->flags & IFF_PROMISC)) {
rctl &= ~E1000_RCTL_UPE;
@@ -2212,7 +2212,7 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
*/
i = 1;
if (use_uc)
- list_for_each_entry(ha, &netdev->uc_list, list) {
+ list_for_each_entry(ha, &netdev->uc.list, list) {
if (i == rar_entries)
break;
iegbe_rar_set(hw, ha->addr, i++);

View File

@@ -1,20 +0,0 @@
--- a/Embedded/src/GbE/iegbe_main.c
+++ b/Embedded/src/GbE/iegbe_main.c
@@ -775,13 +775,13 @@ static int __devinit iegbe_probe(struct
if (err)
return err;
- if (!pci_set_dma_mask(pdev, DMA_64BIT_MASK) &&
- !pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK)) {
+ if (!pci_set_dma_mask(pdev, DMA_BIT_MASK(64)) &&
+ !pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64))) {
pci_using_dac = 1;
} else {
- err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
+ err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
if (err) {
- err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
+ err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
if (err) {
E1000_ERR("No usable DMA configuration, "
"aborting\n");

View File

@@ -1,12 +0,0 @@
--- a/Embedded/src/GbE/iegbe_ethtool.c
+++ b/Embedded/src/GbE/iegbe_ethtool.c
@@ -944,7 +944,8 @@ iegbe_intr_test(struct iegbe_adapter *ad
*data = 0;
/* Hook up test interrupt handler just for this test */
- if(!request_irq(irq, &iegbe_test_intr, 0, netdev->name, netdev)) {
+ if(!request_irq(irq, &iegbe_test_intr, IRQF_PROBE_SHARED, netdev->name,
+ netdev)) {
shared_int = FALSE;
} else if(request_irq(irq, &iegbe_test_intr, IRQF_SHARED,
netdev->name, netdev)){

View File

@@ -1,747 +0,0 @@
--- a/Embedded/src/GbE/iegbe_oem_phy.c
+++ b/Embedded/src/GbE/iegbe_oem_phy.c
@@ -65,6 +65,10 @@ static int32_t iegbe_oem_link_m88_setup(
static int32_t iegbe_oem_set_phy_mode(struct iegbe_hw *hw);
static int32_t iegbe_oem_detect_phy(struct iegbe_hw *hw);
+static int32_t iegbe_oem_link_bcm5481_setup(struct iegbe_hw *hw);
+static int32_t bcm5481_read_18sv (struct iegbe_hw *hw, int sv, uint16_t *data);
+static int32_t oi_phy_setup (struct iegbe_hw *hw);
+
/**
* iegbe_oem_setup_link
* @hw: iegbe_hw struct containing device specific information
@@ -114,6 +118,10 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
}
switch (hw->phy_id) {
+ case BCM5395S_PHY_ID:
+ return E1000_SUCCESS;
+ break;
+
case M88E1000_I_PHY_ID:
case M88E1141_E_PHY_ID:
ret_val = iegbe_oem_link_m88_setup(hw);
@@ -121,6 +129,12 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
return ret_val;
}
break;
+ case BCM5481_PHY_ID:
+ ret_val = iegbe_oem_link_bcm5481_setup(hw);
+ if(ret_val) {
+ return ret_val;
+ }
+ break;
default:
DEBUGOUT("Invalid PHY ID\n");
return -E1000_ERR_PHY_TYPE;
@@ -179,6 +193,51 @@ iegbe_oem_setup_link(struct iegbe_hw *hw
#endif /* ifdef EXTERNAL_MDIO */
}
+/**
+ * iegbe_oem_link_bcm5481_setup
+ * @hw: iegbe_hw struct containing device specific information
+ *
+ * Returns E1000_SUCCESS, negative E1000 error code on failure
+ *
+ * copied verbatim from iegbe_oem_link_m88_setup
+ **/
+static int32_t
+iegbe_oem_link_bcm5481_setup(struct iegbe_hw *hw)
+{
+ int32_t ret_val;
+ uint16_t phy_data;
+
+ //DEBUGFUNC(__func__);
+
+ if(!hw)
+ return -1;
+
+ /* phy_reset_disable is set in iegbe_oem_set_phy_mode */
+ if(hw->phy_reset_disable)
+ return E1000_SUCCESS;
+
+ // Enable MDIX in extended control reg.
+ ret_val = iegbe_oem_read_phy_reg_ex(hw, BCM5481_ECTRL, &phy_data);
+ if(ret_val)
+ {
+ DEBUGOUT("Unable to read BCM5481_ECTRL register\n");
+ return ret_val;
+ }
+
+ phy_data &= ~BCM5481_ECTRL_DISMDIX;
+ ret_val = iegbe_oem_write_phy_reg_ex(hw, BCM5481_ECTRL, phy_data);
+ if(ret_val)
+ {
+ DEBUGOUT("Unable to write BCM5481_ECTRL register\n");
+ return ret_val;
+ }
+
+ ret_val = oi_phy_setup (hw);
+ if (ret_val)
+ return ret_val;
+
+ return E1000_SUCCESS;
+}
/**
* iegbe_oem_link_m88_setup
@@ -340,6 +399,11 @@ iegbe_oem_force_mdi(struct iegbe_hw *hw,
* see iegbe_phy_force_speed_duplex, which does the following for M88
*/
switch (hw->phy_id) {
+ case BCM5395S_PHY_ID:
+ case BCM5481_PHY_ID:
+ DEBUGOUT("WARNING: An empty iegbe_oem_force_mdi() has been called!\n");
+ break;
+
case M88E1000_I_PHY_ID:
case M88E1141_E_PHY_ID:
ret_val = iegbe_oem_read_phy_reg_ex(hw,
@@ -415,6 +479,8 @@ iegbe_oem_phy_reset_dsp(struct iegbe_hw
switch (hw->phy_id) {
case M88E1000_I_PHY_ID:
case M88E1141_E_PHY_ID:
+ case BCM5481_PHY_ID:
+ case BCM5395S_PHY_ID:
DEBUGOUT("No DSP to reset on OEM PHY\n");
break;
default:
@@ -460,6 +526,11 @@ iegbe_oem_cleanup_after_phy_reset(struct
* see iegbe_phy_force_speed_duplex, which does the following for M88
*/
switch (hw->phy_id) {
+ case BCM5395S_PHY_ID:
+ case BCM5481_PHY_ID:
+ DEBUGOUT("WARNING: An empty iegbe_oem_cleanup_after_phy_reset() has been called!\n");
+ break;
+
case M88E1000_I_PHY_ID:
case M88E1141_E_PHY_ID:
/*
@@ -573,6 +644,11 @@ iegbe_oem_set_phy_mode(struct iegbe_hw *
* use iegbe_set_phy_mode as example
*/
switch (hw->phy_id) {
+ case BCM5395S_PHY_ID:
+ case BCM5481_PHY_ID:
+ DEBUGOUT("WARNING: An empty iegbe_oem_set_phy_mode() has been called!\n");
+ break;
+
case M88E1000_I_PHY_ID:
case M88E1141_E_PHY_ID:
ret_val = iegbe_read_eeprom(hw,
@@ -641,6 +717,19 @@ iegbe_oem_detect_phy(struct iegbe_hw *hw
}
hw->phy_type = iegbe_phy_oem;
+{
+ // If MAC2 (BCM5395 switch), manually detect the phy
+ struct iegbe_adapter *adapter;
+ uint32_t device_number;
+ adapter = (struct iegbe_adapter *) hw->back;
+ device_number = PCI_SLOT(adapter->pdev->devfn);
+ if (device_number == ICP_XXXX_MAC_2) {
+ hw->phy_id = BCM5395S_PHY_ID;
+ hw->phy_revision = 0;
+ return E1000_SUCCESS;
+ }
+}
+
ret_val = iegbe_oem_read_phy_reg_ex(hw, PHY_ID1, &phy_id_high);
if(ret_val) {
DEBUGOUT("Unable to read PHY register PHY_ID1\n");
@@ -690,6 +779,8 @@ iegbe_oem_get_tipg(struct iegbe_hw *hw)
switch (hw->phy_id) {
case M88E1000_I_PHY_ID:
case M88E1141_E_PHY_ID:
+ case BCM5481_PHY_ID:
+ case BCM5395S_PHY_ID:
phy_num = DEFAULT_ICP_XXXX_TIPG_IPGT;
break;
default:
@@ -738,6 +829,8 @@ iegbe_oem_phy_is_copper(struct iegbe_hw
switch (hw->phy_id) {
case M88E1000_I_PHY_ID:
case M88E1141_E_PHY_ID:
+ case BCM5481_PHY_ID:
+ case BCM5395S_PHY_ID:
isCopper = TRUE;
break;
default:
@@ -796,13 +889,13 @@ iegbe_oem_get_phy_dev_number(struct iegb
switch(device_number)
{
case ICP_XXXX_MAC_0:
- hw->phy_addr = 0x00;
+ hw->phy_addr = 0x01;
break;
case ICP_XXXX_MAC_1:
- hw->phy_addr = 0x01;
+ hw->phy_addr = 0x02;
break;
case ICP_XXXX_MAC_2:
- hw->phy_addr = 0x02;
+ hw->phy_addr = 0x00;
break;
default: hw->phy_addr = 0x00;
}
@@ -851,6 +944,12 @@ iegbe_oem_mii_ioctl(struct iegbe_adapter
if(!adapter || !ifr) {
return -1;
}
+
+ // If MAC2 (BCM5395 switch) then leave now
+ if ((PCI_SLOT(adapter->pdev->devfn)) == ICP_XXXX_MAC_2) {
+ return -1;
+ }
+
switch (data->reg_num) {
case PHY_CTRL:
if(mii_reg & MII_CR_POWER_DOWN) {
@@ -987,6 +1086,11 @@ void iegbe_oem_get_phy_regs(struct iegbe
* [10] = mdix mode
*/
switch (adapter->hw.phy_id) {
+ case BCM5395S_PHY_ID:
+ case BCM5481_PHY_ID:
+ DEBUGOUT("WARNING: An empty iegbe_oem_get_phy_regs() has been called!\n");
+ break;
+
case M88E1000_I_PHY_ID:
case M88E1141_E_PHY_ID:
if(corrected_len > 0) {
@@ -1068,8 +1172,13 @@ iegbe_oem_phy_loopback(struct iegbe_adap
* Loopback configuration is the same for each of the supported PHYs.
*/
switch (adapter->hw.phy_id) {
+ case BCM5395S_PHY_ID:
+ DEBUGOUT("WARNING: An empty iegbe_oem_phy_loopback() has been called!\n");
+ break;
+
case M88E1000_I_PHY_ID:
case M88E1141_E_PHY_ID:
+ case BCM5481_PHY_ID:
adapter->hw.autoneg = FALSE;
@@ -1182,8 +1291,14 @@ iegbe_oem_loopback_cleanup(struct iegbe_
}
switch (adapter->hw.phy_id) {
+ case BCM5395S_PHY_ID:
+ DEBUGOUT("WARNING: An empty iegbe_oem_loopback_cleanup() has been called!\n");
+ return;
+ break;
+
case M88E1000_I_PHY_ID:
case M88E1141_E_PHY_ID:
+ case BCM5481_PHY_ID:
default:
adapter->hw.autoneg = TRUE;
@@ -1243,6 +1358,11 @@ iegbe_oem_phy_speed_downgraded(struct ie
*/
switch (hw->phy_id) {
+ case BCM5395S_PHY_ID:
+ case BCM5481_PHY_ID:
+ *isDowngraded = 0;
+ break;
+
case M88E1000_I_PHY_ID:
case M88E1141_E_PHY_ID:
ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
@@ -1305,6 +1425,11 @@ iegbe_oem_check_polarity(struct iegbe_hw
*/
switch (hw->phy_id) {
+ case BCM5395S_PHY_ID:
+ case BCM5481_PHY_ID:
+ *polarity = 0;
+ break;
+
case M88E1000_I_PHY_ID:
case M88E1141_E_PHY_ID:
/* return the Polarity bit in the Status register. */
@@ -1367,6 +1492,25 @@ iegbe_oem_phy_is_full_duplex(struct iegb
*/
switch (hw->phy_id) {
+ case BCM5395S_PHY_ID:
+ /* Always full duplex */
+ *isFD = 1;
+ break;
+
+ case BCM5481_PHY_ID:
+ ret_val = iegbe_read_phy_reg(hw, BCM5481_ASTAT, &phy_data);
+ if(ret_val) return ret_val;
+
+ switch (BCM5481_ASTAT_HCD(phy_data)) {
+ case BCM5481_ASTAT_1KBTFD:
+ case BCM5481_ASTAT_100BTXFD:
+ *isFD = 1;
+ break;
+ default:
+ *isFD = 0;
+ }
+ break;
+
case M88E1000_I_PHY_ID:
case M88E1141_E_PHY_ID:
ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
@@ -1423,6 +1567,25 @@ iegbe_oem_phy_is_speed_1000(struct iegbe
*/
switch (hw->phy_id) {
+ case BCM5395S_PHY_ID:
+ /* Always 1000mb */
+ *is1000 = 1;
+ break;
+
+ case BCM5481_PHY_ID:
+ ret_val = iegbe_read_phy_reg(hw, BCM5481_ASTAT, &phy_data);
+ if(ret_val) return ret_val;
+
+ switch (BCM5481_ASTAT_HCD(phy_data)) {
+ case BCM5481_ASTAT_1KBTFD:
+ case BCM5481_ASTAT_1KBTHD:
+ *is1000 = 1;
+ break;
+ default:
+ *is1000 = 0;
+ }
+ break;
+
case M88E1000_I_PHY_ID:
case M88E1141_E_PHY_ID:
ret_val = iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS,
@@ -1478,6 +1641,25 @@ iegbe_oem_phy_is_speed_100(struct iegbe_
* see iegbe_config_mac_to_phy
*/
switch (hw->phy_id) {
+ case BCM5395S_PHY_ID:
+ /* Always 1000Mb, never 100mb */
+ *is100 = 0;
+ break;
+
+ case BCM5481_PHY_ID:
+ ret_val = iegbe_read_phy_reg(hw, BCM5481_ASTAT, &phy_data);
+ if(ret_val) return ret_val;
+
+ switch (BCM5481_ASTAT_HCD(phy_data)) {
+ case BCM5481_ASTAT_100BTXFD:
+ case BCM5481_ASTAT_100BTXHD:
+ *is100 = 1;
+ break;
+ default:
+ *is100 = 0;
+ }
+ break;
+
case M88E1000_I_PHY_ID:
case M88E1141_E_PHY_ID:
ret_val = iegbe_oem_read_phy_reg_ex(hw,
@@ -1535,6 +1717,11 @@ iegbe_oem_phy_get_info(struct iegbe_hw *
* see iegbe_phy_m88_get_info
*/
switch (hw->phy_id) {
+ case BCM5395S_PHY_ID:
+ case BCM5481_PHY_ID:
+ DEBUGOUT("WARNING: An empty iegbe_oem_phy_get_info() has been called!\n");
+ break;
+
case M88E1000_I_PHY_ID:
case M88E1141_E_PHY_ID:
/* The downshift status is checked only once, after link is
@@ -1636,8 +1823,13 @@ iegbe_oem_phy_hw_reset(struct iegbe_hw *
* the M88 used in truxton.
*/
switch (hw->phy_id) {
+ case BCM5395S_PHY_ID:
+ DEBUGOUT("WARNING: An empty iegbe_oem_phy_hw_reset() has been called!\n");
+ break;
+
case M88E1000_I_PHY_ID:
case M88E1141_E_PHY_ID:
+ case BCM5481_PHY_ID:
ret_val = iegbe_oem_read_phy_reg_ex(hw, PHY_CTRL, &phy_data);
if(ret_val) {
DEBUGOUT("Unable to read register PHY_CTRL\n");
@@ -1699,6 +1891,8 @@ iegbe_oem_phy_init_script(struct iegbe_h
switch (hw->phy_id) {
case M88E1000_I_PHY_ID:
case M88E1141_E_PHY_ID:
+ case BCM5481_PHY_ID:
+ case BCM5395S_PHY_ID:
DEBUGOUT("Nothing to do for OEM PHY Init");
break;
default:
@@ -1735,6 +1929,11 @@ iegbe_oem_read_phy_reg_ex(struct iegbe_h
return -1;
}
+ if (hw->phy_id == BCM5395S_PHY_ID) {
+ DEBUGOUT("WARNING: iegbe_oem_read_phy_reg_ex() has been unexpectedly called!\n");
+ return -1;
+ }
+
/* call the GCU func that will read the phy
*
* Make note that the M88 phy is what'll be used on Truxton.
@@ -1782,6 +1981,11 @@ iegbe_oem_set_trans_gasket(struct iegbe_
}
switch (hw->phy_id) {
+ case BCM5395S_PHY_ID:
+ case BCM5481_PHY_ID:
+ DEBUGOUT("WARNING: An empty iegbe_oem_set_trans_gasket() has been called!\n");
+ break;
+
case M88E1000_I_PHY_ID:
case M88E1141_E_PHY_ID:
/* Gasket set correctly for Marvell Phys, so nothing to do */
@@ -1886,6 +2090,8 @@ iegbe_oem_phy_needs_reset_with_mac(struc
switch (hw->phy_id) {
case M88E1000_I_PHY_ID:
case M88E1141_E_PHY_ID:
+ case BCM5481_PHY_ID:
+ case BCM5395S_PHY_ID:
ret_val = FALSE;
break;
default:
@@ -1935,6 +2141,8 @@ iegbe_oem_config_dsp_after_link_change(s
switch (hw->phy_id) {
case M88E1000_I_PHY_ID:
case M88E1141_E_PHY_ID:
+ case BCM5481_PHY_ID:
+ case BCM5395S_PHY_ID:
DEBUGOUT("No DSP to configure on OEM PHY");
break;
default:
@@ -1978,6 +2186,12 @@ iegbe_oem_get_cable_length(struct iegbe_
}
switch (hw->phy_id) {
+ case BCM5395S_PHY_ID:
+ case BCM5481_PHY_ID:
+ *min_length = 0;
+ *max_length = iegbe_igp_cable_length_150;
+ break;
+
case M88E1000_I_PHY_ID:
case M88E1141_E_PHY_ID:
ret_val = iegbe_oem_read_phy_reg_ex(hw,
@@ -2061,6 +2275,23 @@ iegbe_oem_phy_is_link_up(struct iegbe_hw
*/
switch (hw->phy_id) {
+ case BCM5395S_PHY_ID:
+ /* Link always up */
+ *isUp = TRUE;
+ return E1000_SUCCESS;
+ break;
+
+ case BCM5481_PHY_ID:
+ iegbe_oem_read_phy_reg_ex(hw, BCM5481_ESTAT, &phy_data);
+ ret_val = iegbe_oem_read_phy_reg_ex(hw, BCM5481_ESTAT, &phy_data);
+ if(ret_val)
+ {
+ DEBUGOUT("Unable to read PHY register BCM5481_ESTAT\n");
+ return ret_val;
+ }
+ statusMask = BCM5481_ESTAT_LINK;
+ break;
+
case M88E1000_I_PHY_ID:
case M88E1141_E_PHY_ID:
iegbe_oem_read_phy_reg_ex(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);
@@ -2092,3 +2323,210 @@ iegbe_oem_phy_is_link_up(struct iegbe_hw
#endif /* ifdef EXTERNAL_MDIO */
}
+
+
+//-----
+// Read BCM5481 expansion register
+//
+int32_t
+bcm5481_read_ex (struct iegbe_hw *hw, uint16_t reg, uint16_t *data)
+{
+ int ret;
+ uint16_t selector;
+ uint16_t reg_data;
+
+ // Get the current value of bits 15:12
+ ret = iegbe_oem_read_phy_reg_ex (hw, 0x15, &selector);
+ if (ret)
+ return ret;
+
+ // Select the expansion register
+ selector &= 0xf000;
+ selector |= (0xf << 8) | (reg);
+ iegbe_oem_write_phy_reg_ex (hw, 0x17, selector);
+
+ // Read the expansion register
+ ret = iegbe_oem_read_phy_reg_ex (hw, 0x15, &reg_data);
+
+ // De-select the expansion registers.
+ selector &= 0xf000;
+ iegbe_oem_write_phy_reg_ex (hw, 0x17, selector);
+
+ if (ret)
+ return ret;
+
+ *data = reg_data;
+ return ret;
+}
+
+//-----
+// Read reg 0x18 sub-register
+//
+static int32_t
+bcm5481_read_18sv (struct iegbe_hw *hw, int sv, uint16_t *data)
+{
+ int ret;
+ uint16_t tmp_data;
+
+ // Select reg 0x18, sv
+ tmp_data = ((sv & BCM5481_R18H_SV_MASK) << 12) | BCM5481_R18H_SV_MCTRL;
+ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R18H, tmp_data);
+ if(ret)
+ return ret;
+
+ // Read reg 0x18, sv
+ ret = iegbe_oem_read_phy_reg_ex (hw, BCM5481_R18H, &tmp_data);
+ if(ret)
+ return ret;
+
+ *data = tmp_data;
+ return ret;
+}
+
+//-----
+// Read reg 0x1C sub-register
+//
+int32_t
+bcm5481_read_1csv (struct iegbe_hw *hw, int sv, uint16_t *data)
+{
+ int ret;
+ uint16_t tmp_data;
+
+ // Select reg 0x1c, sv
+ tmp_data = ((sv & BCM5481_R1CH_SV_MASK) << BCM5481_R1CH_SV_SHIFT);
+
+ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R1CH, tmp_data);
+ if(ret)
+ return ret;
+
+ // Read reg 0x1c, sv
+ ret = iegbe_oem_read_phy_reg_ex (hw, BCM5481_R1CH, &tmp_data);
+ if(ret)
+ return ret;
+
+ *data = tmp_data;
+ return ret;
+}
+
+//-----
+// Read-modify-write a 0x1C register.
+//
+// hw - hardware access info.
+// reg - 0x1C register to modify.
+// data - bits which should be set.
+// mask - the '1' bits in this argument will be cleared in the data
+// read from 'reg' then 'data' will be or'd in and the result
+// will be written to 'reg'.
+
+int32_t
+bcm5481_rmw_1csv (struct iegbe_hw *hw, uint16_t reg, uint16_t data, uint16_t mask)
+{
+ int32_t ret;
+ uint16_t reg_data;
+
+ ret = 0;
+
+ ret = bcm5481_read_1csv (hw, reg, &reg_data);
+ if (ret)
+ {
+ DEBUGOUT("Unable to read BCM5481 1CH register\n");
+ printk (KERN_ERR "Unable to read BCM5481 1CH register [0x%x]\n", reg);
+ return ret;
+ }
+
+ reg_data &= ~mask;
+ reg_data |= (BCM5481_R1CH_WE | data);
+
+ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R1CH, reg_data);
+ if(ret)
+ {
+ DEBUGOUT("Unable to write BCM5481 1CH register\n");
+ printk (KERN_ERR "Unable to write BCM5481 1CH register\n");
+ return ret;
+ }
+
+ return ret;
+}
+
+int32_t
+oi_phy_setup (struct iegbe_hw *hw)
+{
+ int ret;
+ uint16_t pmii_data;
+ uint16_t mctrl_data;
+ uint16_t cacr_data;
+
+ ret = 0;
+
+ // Set low power mode via reg 0x18, sv010, bit 6
+ // Do a read-modify-write on reg 0x18, sv010 register to preserve existing bits.
+ ret = bcm5481_read_18sv (hw, BCM5481_R18H_SV_PMII, &pmii_data);
+ if (ret)
+ {
+ DEBUGOUT("Unable to read BCM5481_R18H_SV_PMII register\n");
+ printk (KERN_ERR "Unable to read BCM5481_R18H_SV_PMII register\n");
+ return ret;
+ }
+
+ // Set the LPM bit in the data just read and write back to sv010
+ // The shadow register select bits [2:0] are set by reading the sv010
+ // register.
+ pmii_data |= BCM5481_R18H_SV010_LPM;
+ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R18H, pmii_data);
+ if(ret)
+ {
+ DEBUGOUT("Unable to write BCM5481_R18H register\n");
+ printk (KERN_ERR "Unable to write BCM5481_R18H register\n");
+ return ret;
+ }
+
+
+ // Set the RGMII RXD to RXC skew bit in reg 0x18, sv111
+
+ if (bcm5481_read_18sv (hw, BCM5481_R18H_SV_MCTRL, &mctrl_data))
+ {
+ DEBUGOUT("Unable to read BCM5481_R18H_SV_MCTRL register\n");
+ printk (KERN_ERR "Unable to read BCM5481_R18H_SV_MCTRL register\n");
+ return ret;
+ }
+ mctrl_data |= (BCM5481_R18H_WE | BCM5481_R18H_SV111_SKEW);
+
+ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R18H, mctrl_data);
+ if(ret)
+ {
+ DEBUGOUT("Unable to write BCM5481_R18H register\n");
+ printk (KERN_ERR "Unable to write BCM5481_R18H register\n");
+ return ret;
+ }
+
+ // Enable RGMII transmit clock delay in reg 0x1c, sv00011
+ ret = bcm5481_read_1csv (hw, BCM5481_R1CH_CACR, &cacr_data);
+ if (ret)
+ {
+ DEBUGOUT("Unable to read BCM5481_R1CH_CACR register\n");
+ printk (KERN_ERR "Unable to read BCM5481_R1CH_CACR register\n");
+ return ret;
+ }
+
+ cacr_data |= (BCM5481_R1CH_WE | BCM5481_R1CH_CACR_TCD);
+
+ ret = iegbe_oem_write_phy_reg_ex (hw, BCM5481_R1CH, cacr_data);
+ if(ret)
+ {
+ DEBUGOUT("Unable to write BCM5481_R1CH register\n");
+ printk (KERN_ERR "Unable to write BCM5481_R1CH register\n");
+ return ret;
+ }
+
+ // Enable dual link speed indication (0x1c, sv 00010, bit 2)
+ ret = bcm5481_rmw_1csv (hw, BCM5481_R1CH_SC1, BCM5481_R1CH_SC1_LINK, BCM5481_R1CH_SC1_LINK);
+ if (ret)
+ return ret;
+
+ // Enable link and activity on ACTIVITY LED (0x1c, sv 01001, bit 4=1, bit 3=0)
+ ret = bcm5481_rmw_1csv (hw, BCM5481_R1CH_LCTRL, BCM5481_R1CH_LCTRL_ALEN, BCM5481_R1CH_LCTRL_ALEN | BCM5481_R1CH_LCTRL_AEN);
+ if (ret)
+ return ret;
+
+ return ret;
+}
--- a/Embedded/src/GbE/iegbe_oem_phy.h
+++ b/Embedded/src/GbE/iegbe_oem_phy.h
@@ -95,6 +95,8 @@ int32_t iegbe_oem_phy_is_link_up(struct
#define DEFAULT_ICP_XXXX_TIPG_IPGT 8 /* Inter Packet Gap Transmit Time */
#define ICP_XXXX_TIPG_IPGT_MASK 0x000003FFUL
+#define BCM5481_PHY_ID 0x0143BCA0
+#define BCM5395S_PHY_ID 0x0143BCF0
/* Miscellaneous defines */
#ifdef IEGBE_10_100_ONLY
@@ -103,5 +105,65 @@ int32_t iegbe_oem_phy_is_link_up(struct
#define ICP_XXXX_AUTONEG_ADV_DEFAULT 0x2F
#endif
+/* BCM5481 specifics */
+
+#define BCM5481_ECTRL (0x10)
+#define BCM5481_ESTAT (0x11)
+#define BCM5481_RXERR (0x12)
+#define BCM5481_EXPRW (0x15)
+#define BCM5481_EXPACC (0x17)
+#define BCM5481_ASTAT (0x19)
+#define BCM5481_R18H (0x18)
+#define BCM5481_R1CH (0x1c)
+
+/* indirect register access via register 18h */
+
+#define BCM5481_R18H_SV_MASK (7) // Mask for SV bits.
+#define BCM5481_R18H_SV_ACTRL (0) // SV000 Aux. control
+#define BCM5481_R18H_SV_10BT (1) // SV001 10Base-T
+#define BCM5481_R18H_SV_PMII (2) // SV010 Power/MII control
+#define BCM5481_R18H_SV_MTEST (4) // SV100 Misc. test
+#define BCM5481_R18H_SV_MCTRL (7) // SV111 Misc. control
+
+#define BCM5481_R18H_SV001_POL (1 << 13) // Polarity
+#define BCM5481_R18H_SV010_LPM (1 << 6)
+#define BCM5481_R18H_SV111_SKEW (1 << 8)
+#define BCM5481_R18H_WE (1 << 15) // Write enable
+
+// 0x1c registers
+#define BCM5481_R1CH_SV_SHIFT (10)
+#define BCM5481_R1CH_SV_MASK (0x1f)
+#define BCM5481_R1CH_SC1 (0x02) // sv00010 Spare control 1
+#define BCM5481_R1CH_CACR (0x03) // sv00011 Clock alignment control
+#define BCM5481_R1CH_LCTRL (0x09) // sv01001 LED control
+#define BCM5481_R1CH_LEDS1 (0x0d) // sv01101 LED selector 1
+
+// 0x1c common
+#define BCM5481_R1CH_WE (1 << 15) // Write enable
+
+// 0x1c, sv 00010
+#define BCM5481_R1CH_SC1_LINK (1 << 2) // sv00010 Linkspeed
+
+// 0x1c, sv 00011
+#define BCM5481_R1CH_CACR_TCD (1 << 9) // sv00011 RGMII tx clock delay
+
+// 0x1c, sv 01001
+#define BCM5481_R1CH_LCTRL_ALEN (1 << 4) // Activity/Link enable on ACTIVITY LED
+#define BCM5481_R1CH_LCTRL_AEN (1 << 3) // Activity enable on ACTIVITY LED
+
+#define BCM5481_ECTRL_DISMDIX (1 <<14)
+
+#define BCM5481_MCTRL_AUTOMDIX (1 <<9)
+
+#define BCM5481_ESTAT_LINK (1 << 8)
+
+#define BCM5481_ASTAT_ANC (1 << 15)
+#define BCM5481_ASTAT_ANHCD (7 << 8)
+#define BCM5481_ASTAT_HCD(x) ((x >> 8) & 7)
+#define BCM5481_ASTAT_1KBTFD (0x7)
+#define BCM5481_ASTAT_1KBTHD (0x6)
+#define BCM5481_ASTAT_100BTXFD (0x5)
+#define BCM5481_ASTAT_100BTXHD (0x3)
+
#endif /* ifndef _IEGBE_OEM_PHY_H_ */

View File

@@ -1,11 +0,0 @@
--- a/Embedded/src/CAN/icp_can_user.h
+++ b/Embedded/src/CAN/icp_can_user.h
@@ -63,6 +63,8 @@
#ifndef __ICP_CAN_USER_H__
#define __ICP_CAN_USER_H__
+#include <linux/ioctl.h>
+
/*****************************************************************************
* Device IO control codes.
*****************************************************************************/

View File

@@ -1,11 +0,0 @@
--- a/Embedded/src/CAN/can_main.c
+++ b/Embedded/src/CAN/can_main.c
@@ -70,6 +70,8 @@
#include "can_main.h"
#include "can_ioctl.h"
+#include <linux/fs.h>
+
MODULE_AUTHOR("Intel(R) Corporation");
MODULE_DESCRIPTION("Controller Area Network Driver");

View File

@@ -1,23 +0,0 @@
--- a/Embedded/src/CAN/can_main.c
+++ b/Embedded/src/CAN/can_main.c
@@ -654,7 +654,7 @@ int can_dev_io(struct inode *inode, stru
/*****************************************************************************
* Interrupt handler.
*****************************************************************************/
-irqreturn_t can_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t can_irq_handler(int irq, void *dev_id)
{
can_os_t *can_os = (can_os_t *) dev_id;
unsigned int int_status;
--- a/Embedded/src/CAN/can_main.h
+++ b/Embedded/src/CAN/can_main.h
@@ -165,8 +165,7 @@ int can_dev_io(
irqreturn_t can_irq_handler(
int irq,
- void *dev_id,
- struct pt_regs *regs);
+ void *dev_id);
void can_tasklet(
unsigned long arg

View File

@@ -1,40 +0,0 @@
--- a/Embedded/src/CAN/can_main.c
+++ b/Embedded/src/CAN/can_main.c
@@ -214,8 +214,8 @@ int can_pci_probe(struct pci_dev *dev, c
spin_lock_init(&(g_can_os[can_num].int_spinlock));
spin_lock_init(&(g_can_os[can_num].open_spinlock));
- dev->dev.driver_data = (void *) &(g_can_os[can_num]);
- if (!dev->dev.driver_data)
+ dev_set_drvdata(&dev->dev, (void *) &(g_can_os[can_num]));
+ if (!dev_get_drvdata(&dev->dev))
{
printk("Couldn't create CAN device %d. Exiting.\n",
dev->device);
@@ -237,7 +237,7 @@ int can_pci_probe(struct pci_dev *dev, c
*****************************************************************************/
void can_pci_remove(struct pci_dev *dev)
{
- can_os_t *can_os = dev->dev.driver_data;
+ can_os_t *can_os = dev_get_drvdata(&dev->dev);
iounmap(can_os->pci_remap);
icp_can_destroy(can_os->can);
@@ -251,7 +251,7 @@ int can_pci_suspend(struct pci_dev *dev,
{
unsigned int i;
unsigned int int_status;
- can_os_t *can_os = dev->dev.driver_data;
+ can_os_t *can_os = dev_get_drvdata(&dev->dev);
int err;
/* Indicate that we are suspending */
@@ -322,7 +322,7 @@ int can_pci_suspend(struct pci_dev *dev,
int can_pci_resume(struct pci_dev *dev)
{
unsigned int i;
- can_os_t *can_os = dev->dev.driver_data;
+ can_os_t *can_os = dev_get_drvdata(&dev->dev);
/* Restore PCI CFG space */
pci_restore_state(dev);

View File

@@ -1,59 +0,0 @@
--- a/Embedded/src/WDT/iwdt.c
+++ b/Embedded/src/WDT/iwdt.c
@@ -180,19 +180,19 @@ MODULE_PARM_DESC(wdt_scale, "Intel WDT s
module_param(wdt_intr_type, byte, WDT_INT_TYPE_IRQ);
MODULE_PARM_DESC(wdt_intr_type, "Intel WDT interrupt type (default SERIRQ).");
-module_param(wdt_margin1, uint, TIMER_MARGIN);
+module_param(wdt_margin1, uint, 0);
MODULE_PARM_DESC(wdt_margin1, "First stage Intel WDT timeout in steps of 1 ms by default.");
-module_param(wdt_margin2, uint, TIMER_MARGIN);
+module_param(wdt_margin2, uint, 0);
MODULE_PARM_DESC(wdt_margin2, "Second stage Intel WDT timeout in steps of 1 ms by default.");
module_param(nowayout, int, 0);
MODULE_PARM_DESC(nowayout, "Intel WDT can't be stopped once started (default=0)");
-module_param(wdt_index_port, int, 0x4E);
+module_param(wdt_index_port, int, 0);
MODULE_PARM_DESC(wdt_index_port, "WDT Index Port (default 0x4e)");
-module_param(wdt_data_port, int, 0x4E);
+module_param(wdt_data_port, int, 0);
MODULE_PARM_DESC(wdt_data_port, "WDT Data Port (default 0x4f)");
static int wdt_get_iobase(struct pci_dev *dev, u16 *iobase, int *irq);
@@ -218,7 +218,7 @@ static ssize_t wdt_write(struct file *fi
size_t count, loff_t * pos);
static int wdt_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg);
-static irqreturn_t wdt_isr(int irq, void *dev_id, struct pt_regs *regs);
+static irqreturn_t wdt_isr(int irq, void *dev_id);
static void __exit wdt_cleanup(void);
static int __init wdt_init(void);
static int __init wdt_init_one(struct pci_dev *dev,
@@ -255,7 +255,7 @@ static struct pci_driver wdt_driver = {
name: "iwdt",
id_table: lpc_pci_tbl,
probe: wdt_init_one,
- remove: __devexit(wdt_remove_one),
+ remove: __devexit_p(wdt_remove_one),
suspend: wdt_pci_suspend,
resume: wdt_pci_resume,
};
@@ -1393,12 +1393,12 @@ static int wdt_ioctl(struct inode *inode
/*
* Function Name: wdt_isr()
- * Parameter: int irq - irq number, void *dev_id, struct pt_regs *regs
+ * Parameter: int irq - irq number, void *dev_id
* Return Value:: IRQ_NONE - if the interrupt is not for wdt.
* IRQ_HANDLED - if it is for wdt.
* Description: This is the interrupt service routine of the WDT.
*/
-static irqreturn_t wdt_isr(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t wdt_isr(int irq, void *dev_id)
{
u8 val;

View File

@@ -1,22 +0,0 @@
--- a/Embedded/src/EDMA/dma_linux.c
+++ b/Embedded/src/EDMA/dma_linux.c
@@ -149,8 +149,7 @@ int32_t edma_suspend (struct pci_dev *de
int32_t edma_resume(struct pci_dev *dev);
int32_t initialize_edma_device(struct edma_device *device);
-static irqreturn_t edma_irq_handler(int32_t irq, void * dev_id,
- struct pt_regs * regs);
+static irqreturn_t edma_irq_handler(int32_t irq, void * dev_id);
/* Prototypes - Misc. */
@@ -429,8 +428,7 @@ int32_t edma_release(struct inode * inod
* Return Values: HANDLED = 1, NOT_HANDLED = 0
*****************************************************************************/
-static irqreturn_t edma_irq_handler(int32_t irq, void * dev_id,
- struct pt_regs * regs)
+static irqreturn_t edma_irq_handler(int32_t irq, void * dev_id)
{
uint32_t clear_bits;

View File

@@ -1,22 +0,0 @@
--- a/Embedded/src/1588/1588.c
+++ b/Embedded/src/1588/1588.c
@@ -631,7 +631,7 @@ int restore_interrupts(void)
IRQ_NONE => this device did not interrupt
******************************************************************************/
-irqreturn_t timesync_isr(int irq, void *dev_id, struct pt_regs *regs)
+irqreturn_t timesync_isr(int irq, void *dev_id)
{
if ( !ixTimeSyncAccEventAmmsFlagGet() && !ixTimeSyncAccEventAsmsFlagGet()&&
!ixTimeSyncAccEventAtmFlagGet() && !ixTimeSyncAccEventPpsmFlagGet()&&
--- a/Embedded/src/1588/1588.h
+++ b/Embedded/src/1588/1588.h
@@ -128,7 +128,7 @@ int pci_suspend(struct pci_dev *dev, pm_
int pci_resume(struct pci_dev *dev);
int pci_probe(struct pci_dev *dev, const struct pci_device_id *id);
void pci_remove(struct pci_dev *dev);
-irqreturn_t timesync_isr(int irq, void *dev_id, struct pt_regs *regs);
+irqreturn_t timesync_isr(int irq, void *dev_id);
// private functions
int save_reg_state(void);

View File

@@ -1,22 +0,0 @@
--- a/Embedded/src/CAN/can_main.h
+++ b/Embedded/src/CAN/can_main.h
@@ -65,7 +65,7 @@
#include <linux/interrupt.h>
#include <linux/pci.h>
-#include <asm/semaphore.h>
+#include <linux/semaphore.h>
#include <linux/spinlock.h>
#include <linux/cdev.h>
#include <asm/uaccess.h>
--- a/Embedded/src/EDMA/dma_linux.c
+++ b/Embedded/src/EDMA/dma_linux.c
@@ -87,7 +87,7 @@
#include <linux/fcntl.h> /* O_ACCMODE */
#include <asm/system.h> /* cli, *_flags */
#include <asm/uaccess.h> /* copy_to_user */
-#include <asm/semaphore.h>
+#include <linux/semaphore.h>
#include <asm/io.h> /* inb(), outb() */
#include <linux/kmod.h>
#include <linux/ioport.h> /* request_region */

View File

@@ -1,30 +0,0 @@
--- a/Embedded/src/1588/1588.c
+++ b/Embedded/src/1588/1588.c
@@ -72,6 +72,7 @@
*
****************************************************************************/
+#include <linux/sched.h>
#include "1588.h"
MODULE_AUTHOR("Intel(R) Corporation");
--- a/Embedded/src/CAN/can_main.c
+++ b/Embedded/src/CAN/can_main.c
@@ -68,6 +68,7 @@
*
**************************************************************************/
+#include <linux/sched.h>
#include "can_main.h"
#include "can_ioctl.h"
#include <linux/fs.h>
--- a/Embedded/src/WDT/iwdt.c
+++ b/Embedded/src/WDT/iwdt.c
@@ -137,6 +137,7 @@
#include <linux/watchdog.h>
#include <linux/miscdevice.h>
#include <linux/interrupt.h>
+#include <linux/sched.h>
#include "iwdt.h"
MODULE_AUTHOR("Intel(R) Corporation");

View File

@@ -1,31 +0,0 @@
--- a/Embedded/src/GbE/kcompat.h
+++ b/Embedded/src/GbE/kcompat.h
@@ -46,12 +46,6 @@ GPL LICENSE SUMMARY
#include <linux/sched.h>
#include <asm/io.h>
-#ifndef IRQ_HANDLED
-#define irqreturn_t void
-#define IRQ_HANDLED
-#define IRQ_NONE
-#endif
-
#ifndef SET_NETDEV_DEV
#define SET_NETDEV_DEV(net, pdev)
#endif
@@ -748,6 +742,15 @@ extern void dump_stack(void);
#endif /* 2.4.24 */
+/*****************************************************************************/
+#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) )
+#ifndef IRQ_HANDLED
+#define irqreturn_t void
+#define IRQ_HANDLED
+#define IRQ_NONE
+#endif
+#endif /* < 2.6.30 */
+
#endif /* _KCOMPAT_H_ */

View File

@@ -1,11 +0,0 @@
--- a/Embedded/src/GbE/iegbe_main.c
+++ b/Embedded/src/GbE/iegbe_main.c
@@ -3534,7 +3534,7 @@ static int iegbe_clean(struct napi_struc
int tx_cleaned = 0, work_done = 0;
/* Must NOT use netdev_priv macro here. */
- adapter = poll_dev->priv;
+ adapter = netdev_priv(poll_dev);
/* iegbe_clean is called per-cpu. This lock protects
* tx_ring[0] from being cleaned by multiple cpus

View File

@@ -1,91 +0,0 @@
--- a/Embedded/src/GbE/Makefile
+++ b/Embedded/src/GbE/Makefile
@@ -60,19 +60,19 @@ GBE_NAME = iegbe
GCU_NAME = gcu
VERSION_FILE := $(KSRC)/include/linux/version.h
-UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
-CONFIG_FILE := $(KSRC)/include/linux/autoconf.h
+UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
+CONFIG_FILE := $(KSRC)/include/generated/autoconf.h
ifeq (,$(wildcard $(VERSION_FILE)))
$(error Linux kernel source not configured - missing version.h)
endif
ifeq (,$(wildcard $(CONFIG_FILE)))
- $(error Linux kernel source not configured - missing autoconf.h)
+ $(error Linux kernel source not configured - missing autoconf.h)
endif
ifeq (,$(wildcard $(UTS_REL_FILE)))
- $(error Linux kernel source not configured - missing utsrelease.h)
+ $(error Linux kernel source not configured - missing utsrelease.h)
endif
# set the install path
--- a/Embedded/src/1588/Makefile
+++ b/Embedded/src/1588/Makefile
@@ -97,8 +97,8 @@ OUTPUT_PATH ?= /
EXTRA_LDFLAGS += -whole-archive
VERSION_FILE := $(KOBJ)/include/linux/version.h
-UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
-CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
+UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
+CONFIG_FILE := $(KOBJ)/include/generated/autoconf.h
# as of 2.6.16, kernel define UTS_RELEASE has been moved to utsrelease.h
--- a/Embedded/src/CAN/Makefile
+++ b/Embedded/src/CAN/Makefile
@@ -100,8 +100,8 @@ OUTPUT_PATH ?= /
EXTRA_LDFLAGS += -whole-archive
VERSION_FILE := $(KOBJ)/include/linux/version.h
-UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
-CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
+UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
+CONFIG_FILE := $(KOBJ)/include/generated/autoconf.h
# as of 2.6.16, kernel define UTS_RELEASE has been moved to utsrelease.h
--- a/Embedded/src/EDMA/Makefile
+++ b/Embedded/src/EDMA/Makefile
@@ -114,8 +114,8 @@ OUTPUT_PATH ?= /
EXTRA_LDFLAGS += -whole-archive
VERSION_FILE := $(KOBJ)/include/linux/version.h
-UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
-CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
+UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
+CONFIG_FILE := $(KOBJ)/include/generated/autoconf.h
# as of 2.6.16, kernel define UTS_RELEASE has been moved to utsrelease.h
--- a/Embedded/src/GPIO/Makefile
+++ b/Embedded/src/GPIO/Makefile
@@ -97,8 +97,8 @@ OUTPUT_PATH ?= /
EXTRA_LDFLAGS += -whole-archive
VERSION_FILE := $(KOBJ)/include/linux/version.h
-UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
-CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
+UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
+CONFIG_FILE := $(KOBJ)/include/generated/autoconf.h
# as of 2.6.16, kernel define UTS_RELEASE has been moved to utsrelease.h
--- a/Embedded/src/WDT/Makefile
+++ b/Embedded/src/WDT/Makefile
@@ -99,8 +99,8 @@ OUTPUT_PATH ?= /
EXTRA_LDFLAGS += -whole-archive
VERSION_FILE := $(KOBJ)/include/linux/version.h
-UTS_REL_FILE := $(KSRC)/include/linux/utsrelease.h
-CONFIG_FILE := $(KOBJ)/include/linux/autoconf.h
+UTS_REL_FILE := $(KSRC)/include/generated/utsrelease.h
+CONFIG_FILE := $(KOBJ)/include/generated/autoconf.h
# as of 2.6.16, kernel define UTS_RELEASE has been moved to utsrelease.h

View File

@@ -1,392 +0,0 @@
--- a/Embedded/src/GbE/kcompat.h
+++ b/Embedded/src/GbE/kcompat.h
@@ -590,6 +590,10 @@ static inline void _kc_synchronize_irq()
#define ETHTOOL_OPS_COMPAT
#endif
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0))
+#define HAVE_NETIF_MSG 1
+#endif
+
#ifndef HAVE_NETIF_MSG
#define HAVE_NETIF_MSG 1
enum {
--- a/Embedded/src/GbE/iegbe_main.c
+++ b/Embedded/src/GbE/iegbe_main.c
@@ -159,9 +159,9 @@ static void iegbe_smartspeed(struct iegb
static inline int iegbe_82547_fifo_workaround(struct iegbe_adapter *adapter,
struct sk_buff *skb);
-static void iegbe_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp);
-static void iegbe_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
-static void iegbe_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
+static bool iegbe_vlan_used(struct iegbe_adapter *adapter);
+static int iegbe_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
+static int iegbe_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
static void iegbe_restore_vlan(struct iegbe_adapter *adapter);
static int iegbe_notify_reboot(struct notifier_block *,
@@ -324,8 +324,8 @@ static void iegbe_update_mng_vlan(struct
struct net_device *netdev = adapter->netdev;
u16 vid = hw->mng_cookie.vlan_id;
u16 old_vid = adapter->mng_vlan_id;
- if (adapter->vlgrp) {
- if (!vlan_group_get_device(adapter->vlgrp, vid)) {
+ if (iegbe_vlan_used(adapter)) {
+ if (!test_bit(old_vid, adapter->active_vlans)) {
if (hw->mng_cookie.status &
E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) {
iegbe_vlan_rx_add_vid(netdev, vid);
@@ -335,7 +335,7 @@ static void iegbe_update_mng_vlan(struct
if ((old_vid != (u16)E1000_MNG_VLAN_NONE) &&
(vid != old_vid) &&
- !vlan_group_get_device(adapter->vlgrp, old_vid))
+ !test_bit(old_vid, adapter->active_vlans))
iegbe_vlan_rx_kill_vid(netdev, old_vid);
} else
adapter->mng_vlan_id = vid;
@@ -736,7 +736,6 @@ static const struct net_device_ops iegbe
.ndo_do_ioctl = iegbe_ioctl,
.ndo_validate_addr = eth_validate_addr,
- .ndo_vlan_rx_register = iegbe_vlan_rx_register,
.ndo_vlan_rx_add_vid = iegbe_vlan_rx_add_vid,
.ndo_vlan_rx_kill_vid = iegbe_vlan_rx_kill_vid,
#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -767,7 +766,6 @@ static int __devinit iegbe_probe(struct
u16 eeprom_data = 0;
u16 eeprom_apme_mask = E1000_EEPROM_APME;
int bars;
- DECLARE_MAC_BUF(mac);
bars = pci_select_bars(pdev, IORESOURCE_MEM);
err = pci_enable_device(pdev);
@@ -1247,8 +1245,7 @@ static int iegbe_close(struct net_device
if ((hw->mng_cookie.status &
E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
- !(adapter->vlgrp &&
- vlan_group_get_device(adapter->vlgrp, adapter->mng_vlan_id))) {
+ !test_bit(adapter->mng_vlan_id, adapter->active_vlans)) {
iegbe_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
}
return 0;
@@ -2163,11 +2160,13 @@ static void iegbe_set_rx_mode(struct net
struct iegbe_hw *hw = &adapter->hw;
struct netdev_hw_addr *ha;
bool use_uc = false;
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
struct dev_addr_list *mc_ptr;
- u32 rctl;
u32 hash_value;
- int i, rar_entries = E1000_RAR_ENTRIES;
int mta_reg_count = E1000_NUM_MTA_REGISTERS;
+#endif
+ u32 rctl;
+ int i, rar_entries = E1000_RAR_ENTRIES;
/* reserve RAR[14] for LAA over-write work-around */
if (hw->mac_type == iegbe_82571)
@@ -2220,6 +2219,7 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
WARN_ON(i == rar_entries);
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
mc_ptr = netdev->mc_list;
for (; i < rar_entries; i++) {
@@ -2247,6 +2247,7 @@ int mta_reg_count = E1000_NUM_MTA_REGIST
hash_value = iegbe_hash_mc_addr(hw, mc_ptr->da_addr);
iegbe_mta_set(hw, hash_value);
}
+#endif
if (hw->mac_type == iegbe_82542_rev2_0)
iegbe_leave_82542_rst(adapter);
@@ -2821,14 +2822,14 @@ static int iegbe_tx_map(struct iegbe_ada
* Avoid terminating buffers within evenly-aligned
* dwords. */
if(unlikely(adapter->pcix_82544 &&
- !((unsigned long)(frag->page+offset+size-1) & 4) &&
+ !((unsigned long)(frag->page.p+offset+size-1) & 4) &&
size > 4))
size -= 4;
buffer_info->length = size;
buffer_info->dma =
pci_map_page(adapter->pdev,
- frag->page,
+ frag->page.p,
offset,
size,
PCI_DMA_TODEVICE);
@@ -3131,7 +3132,7 @@ static int iegbe_xmit_frame(struct sk_bu
}
}
- if (unlikely(adapter->vlgrp && vlan_tx_tag_present(skb))) {
+ if (unlikely(iegbe_vlan_used(adapter) && vlan_tx_tag_present(skb))) {
tx_flags |= E1000_TX_FLAGS_VLAN;
tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
}
@@ -3832,10 +3833,12 @@ static bool iegbe_clean_rx_irq(struct ie
skb->protocol = eth_type_trans(skb, netdev);
- if (unlikely(adapter->vlgrp &&
+ if (unlikely(iegbe_vlan_used(adapter) &&
(status & E1000_RXD_STAT_VP))) {
- vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
- le16_to_cpu(rx_desc->special));
+ u16 vid;
+
+ vid = le16_to_cpu(rx_desc->special);
+ __vlan_hwaccel_put_tag(skb, vid);
} else {
netif_receive_skb(skb);
}
@@ -3986,9 +3989,10 @@ copydone:
cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP)))
adapter->rx_hdr_split++;
- if(unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
- vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
- le16_to_cpu(rx_desc->wb.middle.vlan));
+ if(unlikely(iegbe_vlan_used(adapter) && (staterr & E1000_RXD_STAT_VP))) {
+ u16 vid;
+ vid = le16_to_cpu(rx_desc->wb.middle.vlan);
+ __vlan_hwaccel_put_tag(skb, vid);
} else {
netif_receive_skb(skb);
}
@@ -4496,17 +4500,25 @@ iegbe_io_write(struct iegbe_hw *hw, unsi
outl(value, port);
}
-static void iegbe_vlan_rx_register(struct net_device *netdev,
- struct vlan_group *grp)
+static bool iegbe_vlan_used(struct iegbe_adapter *adapter)
+{
+ u16 vid;
+
+ for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
+ return true;
+
+ return false;
+}
+
+static void iegbe_vlan_mode(struct net_device *netdev, bool vlan_on)
{
struct iegbe_adapter *adapter = netdev_priv(netdev);
uint32_t ctrl, rctl;
if (!test_bit(__E1000_DOWN, &adapter->flags))
iegbe_irq_disable(adapter);
- adapter->vlgrp = grp;
- if(grp) {
+ if(vlan_on) {
/* enable VLAN tag insert/strip */
ctrl = E1000_READ_REG(&adapter->hw, CTRL);
ctrl |= E1000_CTRL_VME;
@@ -4538,30 +4550,37 @@ static void iegbe_vlan_rx_register(struc
iegbe_irq_enable(adapter);
}
-static void iegbe_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
+static int iegbe_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
{
struct iegbe_adapter *adapter = netdev_priv(netdev);
uint32_t vfta, index;
if((adapter->hw.mng_cookie.status &
E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) &&
(vid == adapter->mng_vlan_id)) {
- return;
+ return 0;
}
+
+ if (!iegbe_vlan_used(adapter))
+ iegbe_vlan_mode(netdev, true);
+
/* add VID to filter table */
index = (vid >> 0x5) & 0x7F;
vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
vfta |= (0x1 << (vid & 0x1F));
iegbe_write_vfta(&adapter->hw, index, vfta);
+
+ set_bit(vid, adapter->active_vlans);
+
+ return 0;
}
-static void iegbe_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
+static int iegbe_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
{
struct iegbe_adapter *adapter = netdev_priv(netdev);
u32 vfta, index;
if (!test_bit(__E1000_DOWN, &adapter->flags))
iegbe_irq_disable(adapter);
- vlan_group_set_device(adapter->vlgrp, vid, NULL);
if (!test_bit(__E1000_DOWN, &adapter->flags))
iegbe_irq_enable(adapter);
@@ -4570,21 +4589,26 @@ static void iegbe_vlan_rx_kill_vid(struc
vfta = E1000_READ_REG_ARRAY(&adapter->hw, VFTA, index);
vfta &= ~(0x1 << (vid & 0x1F));
iegbe_write_vfta(&adapter->hw, index, vfta);
+
+ clear_bit(vid, adapter->active_vlans);
+
+ if (!iegbe_vlan_used(adapter))
+ iegbe_vlan_mode(netdev, false);
+
+ return 0;
}
static void iegbe_restore_vlan(struct iegbe_adapter *adapter)
{
- iegbe_vlan_rx_register(adapter->netdev, adapter->vlgrp);
-
- if (adapter->vlgrp) {
u16 vid;
- for (vid = 0x0; vid < VLAN_GROUP_ARRAY_LEN; vid++) {
- if (!vlan_group_get_device(adapter->vlgrp, vid))
- continue;
+
+ if (!iegbe_vlan_used(adapter))
+ return;
+
+ iegbe_vlan_mode(adapter->netdev, true);
+ for_each_set_bit(vid, adapter->active_vlans, VLAN_N_VID)
iegbe_vlan_rx_add_vid(adapter->netdev, vid);
}
- }
-}
int iegbe_set_spd_dplx(struct iegbe_adapter *adapter, u16 spddplx)
@@ -4864,10 +4888,11 @@ iegbe_resume(struct pci_dev *pdev)
default:
break;
}
-#endif
return 0x0;
}
+#endif
+
#ifdef CONFIG_NET_POLL_CONTROLLER
/*
--- a/Embedded/src/GbE/iegbe_ethtool.c
+++ b/Embedded/src/GbE/iegbe_ethtool.c
@@ -327,6 +327,7 @@ iegbe_set_pauseparam(struct net_device *
return 0;
}
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
static uint32_t
iegbe_get_rx_csum(struct net_device *netdev)
{
@@ -392,6 +393,7 @@ iegbe_set_tso(struct net_device *netdev,
return 0;
}
#endif /* NETIF_F_TSO */
+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)) */
static uint32_t
iegbe_get_msglevel(struct net_device *netdev)
@@ -807,6 +809,7 @@ err_setup_rx:
E1000_82542_##R : E1000_##R; \
return 1; } }
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
static int
iegbe_reg_test(struct iegbe_adapter *adapter, uint64_t *data)
{
@@ -1710,6 +1713,7 @@ iegbe_diag_test(struct net_device *netde
}
msleep_interruptible(0xfa0);
}
+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)) */
static void
iegbe_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
@@ -1812,6 +1816,7 @@ iegbe_set_wol(struct net_device *netdev,
/* bit defines for adapter->led_status */
#define E1000_LED_ON 0
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
static void
iegbe_led_blink_callback(unsigned long data)
{
@@ -1864,6 +1869,7 @@ iegbe_phys_id(struct net_device *netdev,
return 0;
}
+#endif
static int
iegbe_nway_reset(struct net_device *netdev)
@@ -1876,11 +1882,13 @@ iegbe_nway_reset(struct net_device *netd
return 0;
}
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
static int
iegbe_get_stats_count(struct net_device *netdev)
{
return E1000_STATS_LEN;
}
+#endif
static void
iegbe_get_ethtool_stats(struct net_device *netdev,
@@ -1936,6 +1944,8 @@ struct ethtool_ops iegbe_ethtool_ops = {
.set_ringparam = iegbe_set_ringparam,
.get_pauseparam = iegbe_get_pauseparam,
.set_pauseparam = iegbe_set_pauseparam,
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0))
.get_rx_csum = iegbe_get_rx_csum,
.set_rx_csum = iegbe_set_rx_csum,
.get_tx_csum = iegbe_get_tx_csum,
@@ -1946,11 +1956,13 @@ struct ethtool_ops iegbe_ethtool_ops = {
.get_tso = ethtool_op_get_tso,
.set_tso = iegbe_set_tso,
#endif
+
.self_test_count = iegbe_diag_test_count,
.self_test = iegbe_diag_test,
- .get_strings = iegbe_get_strings,
.phys_id = iegbe_phys_id,
.get_stats_count = iegbe_get_stats_count,
+#endif
+ .get_strings = iegbe_get_strings,
.get_ethtool_stats = iegbe_get_ethtool_stats,
};
--- a/Embedded/src/GbE/gcu_main.c
+++ b/Embedded/src/GbE/gcu_main.c
@@ -93,7 +93,7 @@ static struct pci_driver gcu_driver = {
};
static struct gcu_adapter *global_adapter = 0;
-static spinlock_t global_adapter_spinlock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(global_adapter_spinlock);
static unsigned long g_intflags = 0;
MODULE_AUTHOR("Intel(R) Corporation");
--- a/Embedded/src/GbE/iegbe.h
+++ b/Embedded/src/GbE/iegbe.h
@@ -257,7 +257,7 @@ struct iegbe_adapter {
struct timer_list tx_fifo_stall_timer;
struct timer_list watchdog_timer;
struct timer_list phy_info_timer;
- struct vlan_group *vlgrp;
+ unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
uint16_t mng_vlan_id;
uint32_t bd_number;
uint32_t rx_buffer_len;

View File

@@ -1,41 +0,0 @@
--- a/Embedded/src/CAN/can_main.c
+++ b/Embedded/src/CAN/can_main.c
@@ -72,6 +72,7 @@
#include "can_main.h"
#include "can_ioctl.h"
#include <linux/fs.h>
+#include <linux/module.h>
MODULE_AUTHOR("Intel(R) Corporation");
@@ -110,7 +111,7 @@ struct file_operations file_ops = {
.owner = THIS_MODULE,
.read = can_read,
.write = can_write,
- .ioctl = can_dev_io,
+ .unlocked_ioctl = can_dev_io,
.open = can_open,
.release = can_release
};
@@ -594,8 +595,7 @@ int icp_can_reset(can_os_t *can_os)
/*****************************************************************************
* Device IO control function. Used by user apps to configure CAN device.
*****************************************************************************/
-int can_dev_io(struct inode *inode, struct file *filp, unsigned int cmd,
- unsigned long arg)
+long can_dev_io(struct file *filp, unsigned int cmd, unsigned long arg)
{
can_os_t *can_os;
unsigned int err=0;
--- a/Embedded/src/CAN/can_main.h
+++ b/Embedded/src/CAN/can_main.h
@@ -157,8 +157,7 @@ ssize_t can_write(
int icp_can_reset(
can_os_t *can_os);
-int can_dev_io(
- struct inode *inode,
+long can_dev_io(
struct file *filp,
unsigned int cmd,
unsigned long arg);

View File

@@ -1,33 +0,0 @@
--- a/Embedded/src/GPIO/gpio.h
+++ b/Embedded/src/GPIO/gpio.h
@@ -121,8 +121,7 @@ int gpio_init(void);
void gpio_close(void);
int gpio_open(struct inode *inode, struct file *filp);
int gpio_release(struct inode *inode, struct file *filp);
-int gpio_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
- unsigned long arg);
+long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
// private driver functions
int gpio_getpininfo(int Signal, char *pBuff);
@@ -134,7 +133,7 @@ struct file_operations file_ops =
.owner = THIS_MODULE,
.open = gpio_open,
.release = gpio_release,
- .ioctl = gpio_ioctl,
+ .unlocked_ioctl = gpio_ioctl,
};
#endif
--- a/Embedded/src/GPIO/gpio_ref.c
+++ b/Embedded/src/GPIO/gpio_ref.c
@@ -251,8 +251,7 @@ int gpio_release(struct inode *inode, st
0 => success
< 0 => error
******************************************************************************/
-int gpio_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
- unsigned long arg)
+long gpio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
gpio_ioctl_t Info;
u_int bitstr = 0;

View File

@@ -1,31 +0,0 @@
--- a/Embedded/src/WDT/iwdt.c
+++ b/Embedded/src/WDT/iwdt.c
@@ -217,8 +217,7 @@ static int wdt_open(struct inode *inode,
static int wdt_release(struct inode *inode, struct file *file);
static ssize_t wdt_write(struct file *file, const char *data,
size_t count, loff_t * pos);
-static int wdt_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg);
+static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
static irqreturn_t wdt_isr(int irq, void *dev_id);
static void __exit wdt_cleanup(void);
static int __init wdt_init(void);
@@ -243,7 +242,7 @@ static struct pci_device_id lpc_pci_tbl[
static struct file_operations wdt_fops = {
owner: THIS_MODULE,
write: wdt_write,
- ioctl: wdt_ioctl,
+ unlocked_ioctl: wdt_ioctl,
open: wdt_open,
release: wdt_release,
};
@@ -1201,8 +1200,7 @@ char *wdt_get_ioctl_string(unsigned int
* Return Value: 0 - successful, negative value - failed.
* Description: This function is used to provide IO interface.
*/
-static int wdt_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd, unsigned long arg)
+static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
u8 mode=0, scale=0, int_type=0;
u32 u_margin=0, dcount=0;

View File

@@ -1,33 +0,0 @@
--- a/Embedded/src/1588/1588.c
+++ b/Embedded/src/1588/1588.c
@@ -664,8 +664,7 @@ irqreturn_t timesync_isr(int irq, void *
0 => success
< 0 => error
******************************************************************************/
-int timesync_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
- unsigned long arg)
+long timesync_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
wait_queue_head_t *event = NULL;
unsigned int bytes_ret = 0;
--- a/Embedded/src/1588/1588.h
+++ b/Embedded/src/1588/1588.h
@@ -121,8 +121,7 @@ MODULE_DEVICE_TABLE(pci, pci_ids);
// Linux functions
int timesync_open(struct inode *inode, struct file *filp);
int timesync_release(struct inode *inode, struct file *filp);
-int timesync_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
- unsigned long arg);
+long timesync_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
void timesync_close(void);
int pci_suspend(struct pci_dev *dev, pm_message_t state);
int pci_resume(struct pci_dev *dev);
@@ -142,7 +141,7 @@ struct file_operations file_ops =
.owner = THIS_MODULE,
.open = timesync_open,
.release = timesync_release,
- .ioctl = timesync_ioctl,
+ .unlocked_ioctl = timesync_ioctl,
};
// Linux pci operations

View File

@@ -1,44 +0,0 @@
#
# Copyright (C) 2008-2012 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)/kernel.mk
PKG_NAME:=gpio-button-hotplug
PKG_RELEASE:=1
include $(INCLUDE_DIR)/package.mk
define KernelPackage/gpio-button-hotplug
SUBMENU:=Other modules
TITLE:=Simple GPIO Button Hotplug driver
FILES:=$(PKG_BUILD_DIR)/gpio-button-hotplug.ko
AUTOLOAD:=$(call AutoLoad,30,gpio-button-hotplug,1)
KCONFIG:=
endef
define KernelPackage/button-hotplug/description
Kernel module to generate GPIO button hotplug events
endef
MAKE_OPTS:= \
ARCH="$(LINUX_KARCH)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
SUBDIRS="$(PKG_BUILD_DIR)"
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Build/Compile
$(MAKE) -C "$(LINUX_DIR)" \
$(MAKE_OPTS) \
modules
endef
$(eval $(call KernelPackage,gpio-button-hotplug))

View File

@@ -1 +0,0 @@
obj-m += gpio-button-hotplug.o

View File

@@ -1,564 +0,0 @@
/*
* GPIO Button Hotplug driver
*
* Copyright (C) 2012 Felix Fietkau <nbd@openwrt.org>
* Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
*
* Based on the diag.c - GPIO interface driver for Broadcom boards
* Copyright (C) 2006 Mike Baker <mbm@openwrt.org>,
* Copyright (C) 2006-2007 Felix Fietkau <nbd@openwrt.org>
* Copyright (C) 2008 Andy Boyett <agb@openwrt.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/version.h>
#include <linux/kmod.h>
#include <linux/workqueue.h>
#include <linux/skbuff.h>
#include <linux/netlink.h>
#include <linux/kobject.h>
#include <linux/input.h>
#include <linux/platform_device.h>
#include <linux/of_gpio.h>
#include <linux/gpio_keys.h>
#define DRV_NAME "gpio-keys-polled"
#define BH_SKB_SIZE 2048
#define PFX DRV_NAME ": "
#undef BH_DEBUG
#ifdef BH_DEBUG
#define BH_DBG(fmt, args...) printk(KERN_DEBUG "%s: " fmt, DRV_NAME, ##args )
#else
#define BH_DBG(fmt, args...) do {} while (0)
#endif
#define BH_ERR(fmt, args...) printk(KERN_ERR "%s: " fmt, DRV_NAME, ##args )
struct bh_priv {
unsigned long seen;
};
struct bh_event {
const char *name;
char *action;
unsigned long seen;
struct sk_buff *skb;
struct work_struct work;
};
struct bh_map {
unsigned int code;
const char *name;
};
struct gpio_keys_button_data {
struct delayed_work work;
struct bh_priv bh;
int last_state;
int count;
int threshold;
int can_sleep;
};
extern u64 uevent_next_seqnum(void);
#define BH_MAP(_code, _name) \
{ \
.code = (_code), \
.name = (_name), \
}
static struct bh_map button_map[] = {
BH_MAP(BTN_0, "BTN_0"),
BH_MAP(BTN_1, "BTN_1"),
BH_MAP(BTN_2, "BTN_2"),
BH_MAP(BTN_3, "BTN_3"),
BH_MAP(BTN_4, "BTN_4"),
BH_MAP(BTN_5, "BTN_5"),
BH_MAP(BTN_6, "BTN_6"),
BH_MAP(BTN_7, "BTN_7"),
BH_MAP(BTN_8, "BTN_8"),
BH_MAP(BTN_9, "BTN_9"),
BH_MAP(KEY_RESTART, "reset"),
BH_MAP(KEY_RFKILL, "rfkill"),
#ifdef KEY_WPS_BUTTON
BH_MAP(KEY_WPS_BUTTON, "wps"),
#endif /* KEY_WPS_BUTTON */
};
/* -------------------------------------------------------------------------*/
static int bh_event_add_var(struct bh_event *event, int argv,
const char *format, ...)
{
static char buf[128];
char *s;
va_list args;
int len;
if (argv)
return 0;
va_start(args, format);
len = vsnprintf(buf, sizeof(buf), format, args);
va_end(args);
if (len >= sizeof(buf)) {
BH_ERR("buffer size too small\n");
WARN_ON(1);
return -ENOMEM;
}
s = skb_put(event->skb, len + 1);
strcpy(s, buf);
BH_DBG("added variable '%s'\n", s);
return 0;
}
static int button_hotplug_fill_event(struct bh_event *event)
{
int ret;
ret = bh_event_add_var(event, 0, "HOME=%s", "/");
if (ret)
return ret;
ret = bh_event_add_var(event, 0, "PATH=%s",
"/sbin:/bin:/usr/sbin:/usr/bin");
if (ret)
return ret;
ret = bh_event_add_var(event, 0, "SUBSYSTEM=%s", "button");
if (ret)
return ret;
ret = bh_event_add_var(event, 0, "ACTION=%s", event->action);
if (ret)
return ret;
ret = bh_event_add_var(event, 0, "BUTTON=%s", event->name);
if (ret)
return ret;
ret = bh_event_add_var(event, 0, "SEEN=%ld", event->seen);
if (ret)
return ret;
ret = bh_event_add_var(event, 0, "SEQNUM=%llu", uevent_next_seqnum());
return ret;
}
static void button_hotplug_work(struct work_struct *work)
{
struct bh_event *event = container_of(work, struct bh_event, work);
int ret = 0;
event->skb = alloc_skb(BH_SKB_SIZE, GFP_KERNEL);
if (!event->skb)
goto out_free_event;
ret = bh_event_add_var(event, 0, "%s@", event->action);
if (ret)
goto out_free_skb;
ret = button_hotplug_fill_event(event);
if (ret)
goto out_free_skb;
NETLINK_CB(event->skb).dst_group = 1;
broadcast_uevent(event->skb, 0, 1, GFP_KERNEL);
out_free_skb:
if (ret) {
BH_ERR("work error %d\n", ret);
kfree_skb(event->skb);
}
out_free_event:
kfree(event);
}
static int button_hotplug_create_event(const char *name, unsigned long seen,
int pressed)
{
struct bh_event *event;
BH_DBG("create event, name=%s, seen=%lu, pressed=%d\n",
name, seen, pressed);
event = kzalloc(sizeof(*event), GFP_KERNEL);
if (!event)
return -ENOMEM;
event->name = name;
event->seen = seen;
event->action = pressed ? "pressed" : "released";
INIT_WORK(&event->work, (void *)(void *)button_hotplug_work);
schedule_work(&event->work);
return 0;
}
/* -------------------------------------------------------------------------*/
#ifdef CONFIG_HOTPLUG
static int button_get_index(unsigned int code)
{
int i;
for (i = 0; i < ARRAY_SIZE(button_map); i++)
if (button_map[i].code == code)
return i;
return -1;
}
static void button_hotplug_event(struct gpio_keys_button_data *data,
unsigned int type, unsigned int code, int value)
{
struct bh_priv *priv = &data->bh;
unsigned long seen = jiffies;
int btn;
BH_DBG("event type=%u, code=%u, value=%d\n", type, code, value);
if (type != EV_KEY)
return;
btn = button_get_index(code);
if (btn < 0)
return;
button_hotplug_create_event(button_map[btn].name,
(seen - priv->seen) / HZ, value);
priv->seen = seen;
}
#else
static void button_hotplug_event(struct gpio_keys_button_data *data,
unsigned int type, unsigned int code, int value)
{
}
#endif /* CONFIG_HOTPLUG */
struct gpio_keys_polled_dev {
struct delayed_work work;
struct device *dev;
struct gpio_keys_platform_data *pdata;
struct gpio_keys_button_data data[0];
};
static void gpio_keys_polled_check_state(struct gpio_keys_button *button,
struct gpio_keys_button_data *bdata)
{
int state;
if (bdata->can_sleep)
state = !!gpio_get_value_cansleep(button->gpio);
else
state = !!gpio_get_value(button->gpio);
state = !!(state ^ button->active_low);
if (state != bdata->last_state) {
unsigned int type = button->type ?: EV_KEY;
button_hotplug_event(bdata, type, button->code, state);
bdata->count = 0;
bdata->last_state = state;
}
}
static void gpio_keys_polled_queue_work(struct gpio_keys_polled_dev *bdev)
{
struct gpio_keys_platform_data *pdata = bdev->pdata;
unsigned long delay = msecs_to_jiffies(pdata->poll_interval);
if (delay >= HZ)
delay = round_jiffies_relative(delay);
schedule_delayed_work(&bdev->work, delay);
}
static void gpio_keys_polled_poll(struct work_struct *work)
{
struct gpio_keys_polled_dev *bdev =
container_of(work, struct gpio_keys_polled_dev, work.work);
struct gpio_keys_platform_data *pdata = bdev->pdata;
int i;
for (i = 0; i < bdev->pdata->nbuttons; i++) {
struct gpio_keys_button_data *bdata = &bdev->data[i];
if (bdata->count < bdata->threshold)
bdata->count++;
else
gpio_keys_polled_check_state(&pdata->buttons[i], bdata);
}
gpio_keys_polled_queue_work(bdev);
}
static void gpio_keys_polled_open(struct gpio_keys_polled_dev *bdev)
{
struct gpio_keys_platform_data *pdata = bdev->pdata;
int i;
if (pdata->enable)
pdata->enable(bdev->dev);
/* report initial state of the buttons */
for (i = 0; i < pdata->nbuttons; i++)
gpio_keys_polled_check_state(&pdata->buttons[i], &bdev->data[i]);
gpio_keys_polled_queue_work(bdev);
}
#ifdef CONFIG_OF
static struct gpio_keys_platform_data *
gpio_keys_polled_get_devtree_pdata(struct device *dev)
{
struct device_node *node, *pp;
struct gpio_keys_platform_data *pdata;
struct gpio_keys_button *button;
int error;
int nbuttons;
int i;
node = dev->of_node;
if (!node)
return NULL;
nbuttons = of_get_child_count(node);
if (nbuttons == 0)
return NULL;
pdata = kzalloc(sizeof(*pdata) + nbuttons * (sizeof *button),
GFP_KERNEL);
if (!pdata) {
error = -ENOMEM;
goto err_out;
}
pdata->buttons = (struct gpio_keys_button *)(pdata + 1);
pdata->nbuttons = nbuttons;
pdata->rep = !!of_get_property(node, "autorepeat", NULL);
of_property_read_u32(node, "poll-interval", &pdata->poll_interval);
i = 0;
for_each_child_of_node(node, pp) {
enum of_gpio_flags flags;
if (!of_find_property(pp, "gpios", NULL)) {
pdata->nbuttons--;
dev_warn(dev, "Found button without gpios\n");
continue;
}
button = &pdata->buttons[i++];
button->gpio = of_get_gpio_flags(pp, 0, &flags);
button->active_low = flags & OF_GPIO_ACTIVE_LOW;
if (of_property_read_u32(pp, "linux,code", &button->code)) {
dev_err(dev, "Button without keycode: 0x%x\n",
button->gpio);
error = -EINVAL;
goto err_free_pdata;
}
button->desc = of_get_property(pp, "label", NULL);
if (of_property_read_u32(pp, "linux,input-type", &button->type))
button->type = EV_KEY;
button->wakeup = !!of_get_property(pp, "gpio-key,wakeup", NULL);
if (of_property_read_u32(pp, "debounce-interval",
&button->debounce_interval))
button->debounce_interval = 5;
}
if (pdata->nbuttons == 0) {
error = -EINVAL;
goto err_free_pdata;
}
return pdata;
err_free_pdata:
kfree(pdata);
err_out:
return ERR_PTR(error);
}
static struct of_device_id gpio_keys_polled_of_match[] = {
{ .compatible = "gpio-keys-polled", },
{ },
};
MODULE_DEVICE_TABLE(of, gpio_keys_polled_of_match);
#else
static inline struct gpio_keys_platform_data *
gpio_keys_polled_get_devtree_pdata(struct device *dev)
{
return NULL;
}
#endif
static void gpio_keys_polled_close(struct gpio_keys_polled_dev *bdev)
{
struct gpio_keys_platform_data *pdata = bdev->pdata;
cancel_delayed_work_sync(&bdev->work);
if (pdata->disable)
pdata->disable(bdev->dev);
}
static int gpio_keys_polled_probe(struct platform_device *pdev)
{
struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
struct device *dev = &pdev->dev;
struct gpio_keys_polled_dev *bdev;
int error;
int i;
if (!pdata) {
pdata = gpio_keys_polled_get_devtree_pdata(dev);
if (IS_ERR(pdata))
return PTR_ERR(pdata);
if (!pdata) {
dev_err(dev, "missing platform data\n");
return -EINVAL;
}
}
if (!pdata->poll_interval) {
dev_err(dev, "missing poll_interval value\n");
error = -EINVAL;
goto err_free_pdata;
}
bdev = kzalloc(sizeof(struct gpio_keys_polled_dev) +
pdata->nbuttons * sizeof(struct gpio_keys_button_data),
GFP_KERNEL);
if (!bdev) {
dev_err(dev, "no memory for private data\n");
return -ENOMEM;
}
for (i = 0; i < pdata->nbuttons; i++) {
struct gpio_keys_button *button = &pdata->buttons[i];
struct gpio_keys_button_data *bdata = &bdev->data[i];
unsigned int gpio = button->gpio;
if (button->wakeup) {
dev_err(dev, DRV_NAME " does not support wakeup\n");
error = -EINVAL;
goto err_free_gpio;
}
error = gpio_request(gpio,
button->desc ? button->desc : DRV_NAME);
if (error) {
dev_err(dev, "unable to claim gpio %u, err=%d\n",
gpio, error);
goto err_free_gpio;
}
error = gpio_direction_input(gpio);
if (error) {
dev_err(dev,
"unable to set direction on gpio %u, err=%d\n",
gpio, error);
goto err_free_gpio;
}
bdata->can_sleep = gpio_cansleep(gpio);
bdata->last_state = 0;
bdata->threshold = DIV_ROUND_UP(button->debounce_interval,
pdata->poll_interval);
}
bdev->dev = &pdev->dev;
bdev->pdata = pdata;
platform_set_drvdata(pdev, bdev);
INIT_DELAYED_WORK(&bdev->work, gpio_keys_polled_poll);
gpio_keys_polled_open(bdev);
return 0;
err_free_gpio:
while (--i >= 0)
gpio_free(pdata->buttons[i].gpio);
kfree(bdev);
platform_set_drvdata(pdev, NULL);
err_free_pdata:
/* If we have no platform_data, we allocated pdata dynamically. */
if (!dev_get_platdata(&pdev->dev))
kfree(pdata);
return error;
}
static int gpio_keys_polled_remove(struct platform_device *pdev)
{
struct gpio_keys_polled_dev *bdev = platform_get_drvdata(pdev);
struct gpio_keys_platform_data *pdata = bdev->pdata;
int i = pdata->nbuttons;
gpio_keys_polled_close(bdev);
while (--i >= 0)
gpio_free(pdata->buttons[i].gpio);
kfree(bdev);
platform_set_drvdata(pdev, NULL);
return 0;
}
static struct platform_driver gpio_keys_polled_driver = {
.probe = gpio_keys_polled_probe,
.remove = gpio_keys_polled_remove,
.driver = {
.name = DRV_NAME,
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(gpio_keys_polled_of_match),
},
};
static int __init gpio_keys_polled_init(void)
{
return platform_driver_register(&gpio_keys_polled_driver);
}
static void __exit gpio_keys_polled_exit(void)
{
platform_driver_unregister(&gpio_keys_polled_driver);
}
module_init(gpio_keys_polled_init);
module_exit(gpio_keys_polled_exit);
MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
MODULE_AUTHOR("Felix Fietkau <nbd@openwrt.org>");
MODULE_DESCRIPTION("Polled GPIO Buttons hotplug driver");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("platform:" DRV_NAME);

View File

@@ -1,117 +0,0 @@
#
# 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
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=hostap-driver
PKG_VERSION:=0.4.9
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://hostap.epitest.fi/releases/
PKG_MD5SUM:=c7534dc040ab90218257a78488ecd378
include $(INCLUDE_DIR)/package.mk
define KernelPackage/hostap/Default
VERSION:=$(LINUX_VERSION)-$(BOARD)-$(PKG_RELEASE)
SUBMENU:=Wireless Drivers
URL:=http://hostap.epitest.fi/
endef
define KernelPackage/hostap/Default/description
Host AP is a driver for 802.11b wireless cards based on Intersil
Prism2/2.5/3 chipset. It supports so called Host AP mode that allows the
card to act as an IEEE 802.11 access point.
endef
define KernelPackage/hostap
$(call KernelPackage/hostap/Default)
TITLE:=Host AP support for Prism2/2.5/3
DEPENDS:=@PCI_SUPPORT||PCMCIA_SUPPORT +kmod-lib80211 +wireless-tools
KCONFIG:=CONFIG_HOSTAP CONFIG_HOSTAP_FIRMWARE=y CONFIG_HOSTAP_FIRMWARE_NVRAM=y
FILES:=$(LINUX_DIR)/drivers/net/wireless/hostap/hostap.ko
AUTOLOAD:=$(call AutoLoad,60,hostap)
endef
define KernelPackage/hostap/description
$(call KernelPackage/hostap/Default/description)
This package contains the base Host AP driver code that is shared by
different hardware models. You will also need to enable support for
PLX/PCI/CS version of the driver to actually use the driver.
endef
define KernelPackage/hostap-cs
$(call KernelPackage/hostap/Default)
TITLE:=Host AP driver for PCMCIA adaptors
DEPENDS:=@PCMCIA_SUPPORT +kmod-hostap +kmod-pcmcia-core
KCONFIG:=CONFIG_HOSTAP_CS
FILES:=$(LINUX_DIR)/drivers/net/wireless/hostap/hostap_cs.ko
AUTOLOAD:=$(call AutoLoad,60,hostap_cs)
endef
define KernelPackage/hostap-cs/description
$(call KernelPackage/hostap/Default/description)
This package contains the Host AP driver for Prism2/2.5/3 PC cards.
endef
define KernelPackage/hostap-pci
$(call KernelPackage/hostap/Default)
TITLE:=Host AP driver for PCI adaptors
DEPENDS:=@PCI_SUPPORT +kmod-hostap
KCONFIG:=CONFIG_HOSTAP_PCI
FILES:=$(LINUX_DIR)/drivers/net/wireless/hostap/hostap_pci.ko
AUTOLOAD:=$(call AutoLoad,60,hostap_pci)
endef
define KernelPackage/hostap-pci/description
$(call KernelPackage/hostap/Default/description)
This package contains the Host AP driver for Prism2.5 PCI adaptors.
endef
define KernelPackage/hostap-plx
$(call KernelPackage/hostap/Default)
TITLE:=Host AP driver for PLX9052 based PCI adaptors
DEPENDS:=@PCI_SUPPORT +kmod-hostap
KCONFIG:=CONFIG_HOSTAP_PLX
FILES:=$(LINUX_DIR)/drivers/net/wireless/hostap/hostap_plx.ko
AUTOLOAD:=$(call AutoLoad,60,hostap_plx)
endef
define KernelPackage/hostap-plx/description
$(call KernelPackage/hostap/Default/description)
This package contains the Host AP driver for Prism2/2.5/3 in PLX9052
based PCI adaptors.
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Configure
endef
define Build/Compile
endef
define KernelPackage/hostap/install
$(INSTALL_DIR) $(1)/lib/wifi
$(INSTALL_DATA) ./files/lib/wifi/hostap.sh $(1)/lib/wifi
endef
$(eval $(call KernelPackage,hostap))
$(eval $(call KernelPackage,hostap-cs))
$(eval $(call KernelPackage,hostap-pci))
$(eval $(call KernelPackage,hostap-plx))

View File

@@ -1,270 +0,0 @@
#!/bin/sh
append DRIVERS "prism2"
find_prism2_phy() {
local device="$1"
local macaddr="$(config_get "$device" macaddr | tr 'A-Z' 'a-z')"
config_get phy "$device" phy
[ -z "$phy" -a -n "$macaddr" ] && {
cd /proc/net/hostap
for phy in $(ls -d wlan* 2>&-); do
[ "$macaddr" = "$(cat /sys/class/net/${phy}/address)" ] || continue
config_set "$device" phy "$phy"
break
done
config_get phy "$device" phy
}
[ -n "$phy" -a -d "/proc/net/hostap/$phy" ] || {
echo "phy for wifi device $1 not found"
return 1
}
[ -z "$macaddr" ] && {
config_set "$device" macaddr "$(cat /sys/class/net/${phy}/address)"
}
return 0
}
scan_prism2() {
local device="$1"
local mainvif
local wds
[ ${device%[0-9]} = "wlan" ] && config_set "$device" phy "$device" || find_prism2_phy "$device" || {
config_unset "$device" vifs
return 0
}
config_get phy "$device" phy
config_get vifs "$device" vifs
local _c=0
for vif in $vifs; do
config_get_bool disabled "$vif" disabled 0
[ $disabled = 0 ] || continue
config_get mode "$vif" mode
case "$mode" in
adhoc|sta|ap|monitor)
# Only one vif is allowed on AP, station, Ad-hoc or monitor mode
[ -z "$mainvif" ] && {
mainvif="$vif"
config_set "$vif" ifname "$phy"
}
;;
wds)
config_get ssid "$vif" ssid
[ -z "$ssid" ] && continue
config_set "$vif" ifname "${phy}wds${_c}"
_c=$(($_c + 1))
addr="$ssid"
${addr:+append wds "$vif"}
;;
*) echo "$device($vif): Invalid mode, ignored."; continue;;
esac
done
config_set "$device" vifs "${mainvif:+$mainvif }${wds:+$wds}"
}
disable_prism2() (
local device="$1"
find_prism2_phy "$device" || return 0
config_get phy "$device" phy
set_wifi_down "$device"
include /lib/network
while read line < /proc/net/hostap/${phy}/wds; do
set $line
[ -f "/var/run/wifi-${1}.pid" ] &&
kill "$(cat "/var/run/wifi-${1}.pid")"
ifconfig "$1" down
unbridge "$1"
iwpriv "$phy" wds_del "$2"
done
unbridge "$phy"
return 0
)
enable_prism2() {
local device="$1"
find_prism2_phy "$device" || return 0
config_get phy "$device" phy
config_get rxantenna "$device" rxantenna
config_get txantenna "$device" txantenna
config_get_bool diversity "$device" diversity
[ -n "$diversity" ] && {
rxantenna="1"
txantenna="1"
}
[ -n "$rxantenna" ] && iwpriv "$phy" antsel_rx "$rxantenna"
[ -n "$txantenna" ] && iwpriv "$phy" antsel_tx "$txantenna"
config_get channel "$device" channel
[ -n "$channel" ] && iwconfig "$phy" channel "$channel" >/dev/null 2>/dev/null
config_get txpower "$device" txpower
[ -n "$txpower" ] && iwconfig "$phy" txpower "${txpower%%.*}"
config_get vifs "$device" vifs
local first=1
for vif in $vifs; do
config_get ifname "$vif" ifname
config_get ssid "$vif" ssid
config_get mode "$vif" mode
[ "$mode" = "wds" ] || iwconfig "$phy" essid ${ssid:+-- }"${ssid:-any}"
case "$mode" in
sta)
iwconfig "$phy" mode managed
config_get addr "$device" bssid
[ -z "$addr" ] || {
iwconfig "$phy" ap "$addr"
}
;;
ap) iwconfig "$phy" mode master;;
wds) iwpriv "$phy" wds_add "$ssid";;
adhoc) iwconfig "$phy" mode ad-hoc;;
*) iwconfig "$phy" mode "$mode";;
esac
[ "$first" = 1 ] && {
config_get rate "$vif" rate
[ -n "$rate" ] && iwconfig "$phy" rate "${rate%%.*}"
config_get_bool hidden "$vif" hidden 0
iwpriv "$phy" enh_sec "$hidden"
config_get frag "$vif" frag
[ -n "$frag" ] && iwconfig "$phy" frag "${frag%%.*}"
config_get rts "$vif" rts
[ -n "$rts" ] && iwconfig "$phy" rts "${rts%%.*}"
config_get maclist "$vif" maclist
[ -n "$maclist" ] && {
# flush MAC list
iwpriv "$phy" maccmd 3
for mac in $maclist; do
iwpriv "$phy" addmac "$mac"
done
}
config_get macpolicy "$vif" macpolicy
case "$macpolicy" in
allow)
iwpriv "$phy" maccmd 2
;;
deny)
iwpriv "$phy" maccmd 1
;;
*)
# default deny policy if mac list exists
[ -n "$maclist" ] && iwpriv "$phy" maccmd 1
;;
esac
# kick all stations if we have policy explicitly set
[ -n "$macpolicy" ] && iwpriv "$phy" maccmd 4
}
config_get enc "$vif" encryption
case "$enc" in
WEP|wep)
for idx in 1 2 3 4; do
config_get key "$vif" "key${idx}"
iwconfig "$ifname" enc "[$idx]" "${key:-off}"
done
config_get key "$vif" key
key="${key:-1}"
case "$key" in
[1234]) iwconfig "$ifname" enc "[$key]";;
*) iwconfig "$ifname" enc "$key";;
esac
;;
psk*|wpa*)
start_hostapd=1
config_get key "$vif" key
;;
esac
local net_cfg bridge
net_cfg="$(find_net_config "$vif")"
[ -z "$net_cfg" ] || {
bridge="$(bridge_interface "$net_cfg")"
config_set "$vif" bridge "$bridge"
start_net "$ifname" "$net_cfg"
}
set_wifi_up "$vif" "$ifname"
case "$mode" in
ap)
if [ -n "$start_hostapd" ] && eval "type hostapd_setup_vif" 2>/dev/null >/dev/null; then
hostapd_setup_vif "$vif" hostap || {
echo "enable_prism2($device): Failed to set up hostapd for interface $ifname" >&2
# make sure this wifi interface won't accidentally stay open without encryption
ifconfig "$ifname" down
continue
}
fi
;;
wds|sta)
if eval "type wpa_supplicant_setup_vif" 2>/dev/null >/dev/null; then
wpa_supplicant_setup_vif "$vif" wext || {
echo "enable_prism2($device): Failed to set up wpa_supplicant for interface $ifname" >&2
ifconfig "$ifname" down
continue
}
fi
;;
esac
first=0
done
}
check_prism2_device() {
[ ${1%[0-9]} = "wlan" ] && config_set "$1" phy "$1"
config_get phy "$1" phy
[ -z "$phy" ] && {
find_prism2_phy "$1" >/dev/null || return 0
config_get phy "$1" phy
}
[ "$phy" = "$dev" ] && found=1
}
detect_prism2() {
devidx=0
config_load wireless
while :; do
config_get type "radio$devidx" type
[ -n "$type" ] || break
devidx=$(($devidx + 1))
done
cd /proc/net/hostap
[ -d wlan* ] || return
for dev in $(ls -d wlan* 2>&-); do
found=0
config_foreach check_prism2_device wifi-device
[ "$found" -gt 0 ] && continue
cat <<EOF
config wifi-device radio$devidx
option type prism2
option channel 11
option macaddr $(cat /sys/class/net/${dev}/address)
# REMOVE THIS LINE TO ENABLE WIFI:
option disabled 1
config wifi-iface
option device radio$devidx
option network lan
option mode ap
option ssid OpenWrt
option encryption none
EOF
devidx=$(($devidx + 1))
done
}

View File

@@ -1,175 +0,0 @@
diff -Naur hostap-driver-0.3.7/driver/modules/hostap.c hostap-driver-0.3.7-patched/driver/modules/hostap.c
--- hostap-driver-0.3.7/driver/modules/hostap.c 2004-08-28 06:26:46.000000000 +0300
+++ hostap-driver-0.3.7-patched/driver/modules/hostap.c 2005-04-20 17:20:56.000000000 +0300
@@ -1164,6 +1164,36 @@
return ret;
}
+/* BUG FIX: Restore power setting value when lost due to F/W bug */
+
+int hostap_restore_power(struct net_device *dev)
+{
+ struct hostap_interface *iface = dev->priv;
+ local_info_t *local = iface->local;
+
+ u16 val;
+ int ret = 0;
+
+ if (local->txpower_type == PRISM2_TXPOWER_OFF) {
+ val = 0xff; /* use all standby and sleep modes */
+ ret = local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
+ HFA386X_CR_A_D_TEST_MODES2,
+ &val, NULL);
+ }
+
+#ifdef RAW_TXPOWER_SETTING
+ if (local->txpower_type == PRISM2_TXPOWER_FIXED) {
+ val = HFA384X_TEST_CFG_BIT_ALC;
+ local->func->cmd(dev, HFA384X_CMDCODE_TEST |
+ (HFA384X_TEST_CFG_BITS << 8), 0, &val, NULL);
+ val = prism2_txpower_dBm_to_hfa386x(local->txpower);
+ ret = (local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
+ HFA386X_CR_MANUAL_TX_POWER, &val, NULL));
+ }
+#endif /* RAW_TXPOWER_SETTING */
+ return (ret ? -EOPNOTSUPP : 0);
+}
+
struct proc_dir_entry *hostap_proc;
@@ -1214,6 +1244,7 @@
EXPORT_SYMBOL(hostap_set_hostapd_sta);
EXPORT_SYMBOL(hostap_add_interface);
EXPORT_SYMBOL(hostap_remove_interface);
+EXPORT_SYMBOL(hostap_restore_power);
EXPORT_SYMBOL(prism2_update_comms_qual);
module_init(hostap_init);
diff -Naur hostap-driver-0.3.7/driver/modules/hostap.h hostap-driver-0.3.7-patched/driver/modules/hostap.h
--- hostap-driver-0.3.7/driver/modules/hostap.h 2003-11-30 04:14:26.000000000 +0200
+++ hostap-driver-0.3.7-patched/driver/modules/hostap.h 2005-04-20 17:21:23.000000000 +0300
@@ -36,6 +36,7 @@
const char *prefix, const char *name);
void hostap_remove_interface(struct net_device *dev, int rtnl_locked,
int remove_from_list);
+int hostap_restore_power(struct net_device *dev);
int prism2_update_comms_qual(struct net_device *dev);
int prism2_sta_send_mgmt(local_info_t *local, u8 *dst, u8 stype,
u8 *body, size_t bodylen);
diff -Naur hostap-driver-0.3.7/driver/modules/hostap_ap.c hostap-driver-0.3.7-patched/driver/modules/hostap_ap.c
--- hostap-driver-0.3.7/driver/modules/hostap_ap.c 2005-01-24 04:52:00.000000000 +0200
+++ hostap-driver-0.3.7-patched/driver/modules/hostap_ap.c 2005-04-21 20:06:12.000000000 +0300
@@ -2346,13 +2346,13 @@
addr[count].sa_family = ARPHRD_ETHER;
memcpy(addr[count].sa_data, sta->addr, ETH_ALEN);
if (sta->last_rx_silence == 0)
- qual[count].qual = sta->last_rx_signal < 27 ?
- 0 : (sta->last_rx_signal - 27) * 92 / 127;
+ qual[count].qual = (sta->last_rx_signal - 156) == 0 ?
+ 0 : (sta->last_rx_signal - 156) * 92 / 64;
else
- qual[count].qual = sta->last_rx_signal -
- sta->last_rx_silence - 35;
- qual[count].level = HFA384X_LEVEL_TO_dBm(sta->last_rx_signal);
- qual[count].noise = HFA384X_LEVEL_TO_dBm(sta->last_rx_silence);
+ qual[count].qual = (sta->last_rx_signal -
+ sta->last_rx_silence) * 92 / 64;
+ qual[count].level = sta->last_rx_signal;
+ qual[count].noise = sta->last_rx_silence;
qual[count].updated = sta->last_rx_updated;
sta->last_rx_updated = 0;
@@ -2413,13 +2413,13 @@
memset(&iwe, 0, sizeof(iwe));
iwe.cmd = IWEVQUAL;
if (sta->last_rx_silence == 0)
- iwe.u.qual.qual = sta->last_rx_signal < 27 ?
- 0 : (sta->last_rx_signal - 27) * 92 / 127;
+ iwe.u.qual.qual = (sta->last_rx_signal -156) == 0 ?
+ 0 : (sta->last_rx_signal - 156) * 92 / 64;
else
- iwe.u.qual.qual = sta->last_rx_signal -
- sta->last_rx_silence - 35;
- iwe.u.qual.level = HFA384X_LEVEL_TO_dBm(sta->last_rx_signal);
- iwe.u.qual.noise = HFA384X_LEVEL_TO_dBm(sta->last_rx_silence);
+ iwe.u.qual.qual = (sta->last_rx_signal -
+ sta->last_rx_silence) * 92 / 64;
+ iwe.u.qual.level = sta->last_rx_signal;
+ iwe.u.qual.noise = sta->last_rx_silence;
iwe.u.qual.updated = sta->last_rx_updated;
iwe.len = IW_EV_QUAL_LEN;
current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
diff -Naur hostap-driver-0.3.7/driver/modules/hostap_config.h hostap-driver-0.3.7-patched/driver/modules/hostap_config.h
--- hostap-driver-0.3.7/driver/modules/hostap_config.h 2005-02-12 18:12:56.000000000 +0200
+++ hostap-driver-0.3.7-patched/driver/modules/hostap_config.h 2005-04-20 17:25:23.000000000 +0300
@@ -94,6 +94,12 @@
*/
/* #define PRISM2_NO_STATION_MODES */
+/* Enable TX power Setting functions
+ * (min att = -128 , max att = 127)
+ */
+
+#define RAW_TXPOWER_SETTING
+
/* Use Linux crypto API instead of own encryption implementation whenever
* possible. */
/* #define HOSTAP_USE_CRYPTO_API */
diff -Naur hostap-driver-0.3.7/driver/modules/hostap_hw.c hostap-driver-0.3.7-patched/driver/modules/hostap_hw.c
--- hostap-driver-0.3.7/driver/modules/hostap_hw.c 2005-02-05 09:20:09.000000000 +0200
+++ hostap-driver-0.3.7-patched/driver/modules/hostap_hw.c 2005-04-20 17:25:55.000000000 +0300
@@ -1039,6 +1039,7 @@
dev->name, local->fragm_threshold);
}
+ hostap_restore_power(dev);
return res;
}
diff -Naur hostap-driver-0.3.7/driver/modules/hostap_info.c hostap-driver-0.3.7-patched/driver/modules/hostap_info.c
--- hostap-driver-0.3.7/driver/modules/hostap_info.c 2004-02-29 20:05:44.000000000 +0200
+++ hostap-driver-0.3.7-patched/driver/modules/hostap_info.c 2005-04-20 17:26:36.000000000 +0300
@@ -418,6 +418,11 @@
}
/* Get BSSID if we have a valid AP address */
+
+ if ( val == HFA384X_LINKSTATUS_CONNECTED ||
+ val == HFA384X_LINKSTATUS_DISCONNECTED )
+ hostap_restore_power(local->dev);
+
if (connected) {
netif_carrier_on(local->dev);
netif_carrier_on(local->ddev);
diff -Naur hostap-driver-0.3.7/driver/modules/hostap_ioctl.c hostap-driver-0.3.7-patched/driver/modules/hostap_ioctl.c
--- hostap-driver-0.3.7/driver/modules/hostap_ioctl.c 2004-11-22 08:03:05.000000000 +0200
+++ hostap-driver-0.3.7-patched/driver/modules/hostap_ioctl.c 2005-04-20 17:42:41.000000000 +0300
@@ -1453,23 +1453,20 @@
val = 255;
tmp = val;
- tmp >>= 2;
- return -12 - tmp;
+ return tmp;
}
static u16 prism2_txpower_dBm_to_hfa386x(int val)
{
signed char tmp;
- if (val > 20)
- return 128;
- else if (val < -43)
+ if (val > 127)
return 127;
+ else if (val < -128)
+ return 128;
tmp = val;
- tmp = -12 - tmp;
- tmp <<= 2;
return (unsigned char) tmp;
}

View File

@@ -1,53 +0,0 @@
#
# Copyright (C) 2008 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)/kernel.mk
PKG_NAME:=i2c-gpio-custom
PKG_RELEASE:=2
include $(INCLUDE_DIR)/package.mk
define KernelPackage/i2c-gpio-custom
SUBMENU:=I2C support
TITLE:=Custom GPIO-based I2C device
DEPENDS:=@GPIO_SUPPORT +kmod-i2c-core +kmod-i2c-gpio
FILES:=$(PKG_BUILD_DIR)/i2c-gpio-custom.ko
KCONFIG:=
endef
define KernelPackage/i2c-gpio-custom/description
Kernel module for register a custom i2c-gpio platform device.
endef
EXTRA_KCONFIG:= \
CONFIG_I2C_GPIO_CUSTOM=m
EXTRA_CFLAGS:= \
$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \
MAKE_OPTS:= \
ARCH="$(LINUX_KARCH)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
SUBDIRS="$(PKG_BUILD_DIR)" \
EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
$(EXTRA_KCONFIG)
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Build/Compile
$(MAKE) -C "$(LINUX_DIR)" \
$(MAKE_OPTS) \
modules
endef
$(eval $(call KernelPackage,i2c-gpio-custom))

View File

@@ -1,10 +0,0 @@
config I2C_GPIO_CUSTOM
tristate "Custom GPIO-based I2C driver"
depends on GENERIC_GPIO
select I2C_GPIO
help
This is an I2C driver to register 1 to 4 custom I2C buses using
GPIO lines.
This support is also available as a module. If so, the module
will be called i2c-gpio-custom.

View File

@@ -1 +0,0 @@
obj-${CONFIG_I2C_GPIO_CUSTOM} += i2c-gpio-custom.o

View File

@@ -1,198 +0,0 @@
/*
* Custom GPIO-based I2C driver
*
* Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* ---------------------------------------------------------------------------
*
* The behaviour of this driver can be altered by setting some parameters
* from the insmod command line.
*
* The following parameters are adjustable:
*
* bus0 These four arguments can be arrays of
* bus1 1-8 unsigned integers as follows:
* bus2
* bus3 <id>,<sda>,<scl>,<udelay>,<timeout>,<sda_od>,<scl_od>,<scl_oo>
*
* where:
*
* <id> ID to used as device_id for the corresponding bus (required)
* <sda> GPIO pin ID to used for SDA (required)
* <scl> GPIO pin ID to used for SCL (required)
* <udelay> signal toggle delay.
* <timeout> clock stretching timeout.
* <sda_od> SDA is configured as open drain.
* <scl_od> SCL is configured as open drain.
* <scl_oo> SCL output drivers cannot be turned off.
*
* See include/i2c-gpio.h for more information about the parameters.
*
* If this driver is built into the kernel, you can use the following kernel
* command line parameters, with the same values as the corresponding module
* parameters listed above:
*
* i2c-gpio-custom.bus0
* i2c-gpio-custom.bus1
* i2c-gpio-custom.bus2
* i2c-gpio-custom.bus3
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/i2c-gpio.h>
#define DRV_NAME "i2c-gpio-custom"
#define DRV_DESC "Custom GPIO-based I2C driver"
#define DRV_VERSION "0.1.1"
#define PFX DRV_NAME ": "
#define BUS_PARAM_ID 0
#define BUS_PARAM_SDA 1
#define BUS_PARAM_SCL 2
#define BUS_PARAM_UDELAY 3
#define BUS_PARAM_TIMEOUT 4
#define BUS_PARAM_SDA_OD 5
#define BUS_PARAM_SCL_OD 6
#define BUS_PARAM_SCL_OO 7
#define BUS_PARAM_REQUIRED 3
#define BUS_PARAM_COUNT 8
#define BUS_COUNT_MAX 4
static unsigned int bus0[BUS_PARAM_COUNT] __initdata;
static unsigned int bus1[BUS_PARAM_COUNT] __initdata;
static unsigned int bus2[BUS_PARAM_COUNT] __initdata;
static unsigned int bus3[BUS_PARAM_COUNT] __initdata;
static unsigned int bus_nump[BUS_COUNT_MAX] __initdata;
#define BUS_PARM_DESC \
" config -> id,sda,scl[,udelay,timeout,sda_od,scl_od,scl_oo]"
module_param_array(bus0, uint, &bus_nump[0], 0);
MODULE_PARM_DESC(bus0, "bus0" BUS_PARM_DESC);
module_param_array(bus1, uint, &bus_nump[1], 0);
MODULE_PARM_DESC(bus1, "bus1" BUS_PARM_DESC);
module_param_array(bus2, uint, &bus_nump[2], 0);
MODULE_PARM_DESC(bus2, "bus2" BUS_PARM_DESC);
module_param_array(bus3, uint, &bus_nump[3], 0);
MODULE_PARM_DESC(bus3, "bus3" BUS_PARM_DESC);
static struct platform_device *devices[BUS_COUNT_MAX];
static unsigned int nr_devices;
static void i2c_gpio_custom_cleanup(void)
{
int i;
for (i = 0; i < nr_devices; i++)
if (devices[i])
platform_device_put(devices[i]);
}
static int __init i2c_gpio_custom_add_one(unsigned int id, unsigned int *params)
{
struct platform_device *pdev;
struct i2c_gpio_platform_data pdata;
int err;
if (!bus_nump[id])
return 0;
if (bus_nump[id] < BUS_PARAM_REQUIRED) {
printk(KERN_ERR PFX "not enough parameters for bus%d\n", id);
err = -EINVAL;
goto err;
}
pdev = platform_device_alloc("i2c-gpio", params[BUS_PARAM_ID]);
if (!pdev) {
err = -ENOMEM;
goto err;
}
pdata.sda_pin = params[BUS_PARAM_SDA];
pdata.scl_pin = params[BUS_PARAM_SCL];
pdata.udelay = params[BUS_PARAM_UDELAY];
pdata.timeout = params[BUS_PARAM_TIMEOUT];
pdata.sda_is_open_drain = params[BUS_PARAM_SDA_OD] != 0;
pdata.scl_is_open_drain = params[BUS_PARAM_SCL_OD] != 0;
pdata.scl_is_output_only = params[BUS_PARAM_SCL_OO] != 0;
err = platform_device_add_data(pdev, &pdata, sizeof(pdata));
if (err)
goto err_put;
err = platform_device_add(pdev);
if (err)
goto err_put;
devices[nr_devices++] = pdev;
return 0;
err_put:
platform_device_put(pdev);
err:
return err;
}
static int __init i2c_gpio_custom_probe(void)
{
int err;
printk(KERN_INFO DRV_DESC " version " DRV_VERSION "\n");
err = i2c_gpio_custom_add_one(0, bus0);
if (err) goto err;
err = i2c_gpio_custom_add_one(1, bus1);
if (err) goto err;
err = i2c_gpio_custom_add_one(2, bus2);
if (err) goto err;
err = i2c_gpio_custom_add_one(3, bus3);
if (err) goto err;
if (!nr_devices) {
printk(KERN_ERR PFX "no bus parameter(s) specified\n");
err = -ENODEV;
goto err;
}
return 0;
err:
i2c_gpio_custom_cleanup();
return err;
}
#ifdef MODULE
static int __init i2c_gpio_custom_init(void)
{
return i2c_gpio_custom_probe();
}
module_init(i2c_gpio_custom_init);
static void __exit i2c_gpio_custom_exit(void)
{
i2c_gpio_custom_cleanup();
}
module_exit(i2c_gpio_custom_exit);
#else
subsys_initcall(i2c_gpio_custom_probe);
#endif /* MODULE*/
MODULE_LICENSE("GPL v2");
MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org >");
MODULE_DESCRIPTION(DRV_DESC);
MODULE_VERSION(DRV_VERSION);

View File

@@ -1,77 +0,0 @@
#
# Copyright (C) 2008 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)/kernel.mk
PKG_NAME:=mmc-over-gpio
PKG_RELEASE:=4
include $(INCLUDE_DIR)/package.mk
define KernelPackage/mmc-over-gpio
SUBMENU:=Other modules
DEPENDS:=@GPIO_SUPPORT +kmod-mmc-spi +kmod-spi-gpio-old +kmod-fs-configfs
KCONFIG:=CONFIG_GPIOMMC
TITLE:=MMC/SD card over GPIO support
FILES:=$(LINUX_DIR)/drivers/mmc/host/gpiommc.ko
AUTOLOAD:=$(call AutoLoad,93,gpiommc)
MENU:=1
endef
define Package/kmod-mmc-over-gpio/config
menu "Configuration"
depends on PACKAGE_kmod-mmc-over-gpio
config KMOD_MMC_OVER_GPIO_DI_PIN
int "GPIO DI (Data-In) pin"
default 1
config KMOD_MMC_OVER_GPIO_DO_PIN
int "GPIO DO (Data-Out) pin"
default 3
config KMOD_MMC_OVER_GPIO_CLK_PIN
int "GPIO CLK (Clock) pin"
default 4
config KMOD_MMC_OVER_GPIO_CS_PIN
int "GPIO CS (Chip-Select) pin"
default 7
endmenu
endef
define KernelPackage/mmc-over-gpio/description
Support for driving an MMC/SD card over GPIO pins via SPI.
endef
define KernelPackage/mmc-over-gpio/conffiles
/etc/config/mmc_over_gpio
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Compile
endef
define KernelPackage/mmc-over-gpio/install
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/mmc_over_gpio.config $(1)/etc/config/mmc_over_gpio
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/mmc_over_gpio.init $(1)/etc/init.d/mmc_over_gpio
$(SED) 's,@GPIO_DI_PIN@,$(CONFIG_KMOD_MMC_OVER_GPIO_DI_PIN),g' \
-e 's,@GPIO_DO_PIN@,$(CONFIG_KMOD_MMC_OVER_GPIO_DO_PIN),g' \
-e 's,@GPIO_CLK_PIN@,$(CONFIG_KMOD_MMC_OVER_GPIO_CLK_PIN),g' \
-e 's,@GPIO_CS_PIN@,$(CONFIG_KMOD_MMC_OVER_GPIO_CS_PIN),g' \
$(1)/etc/config/mmc_over_gpio
endef
$(eval $(call KernelPackage,mmc-over-gpio))

View File

@@ -1,8 +0,0 @@
config 'mmc_over_gpio'
option 'name' 'default'
option 'enabled' '0'
option 'DI_pin' '@GPIO_DI_PIN@'
option 'DO_pin' '@GPIO_DO_PIN@'
option 'CLK_pin' '@GPIO_CLK_PIN@'
option 'CS_pin' '@GPIO_CS_PIN@'
option 'mode' '0'

View File

@@ -1,83 +0,0 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2008 OpenWrt.org
START=90
CONFIGFS_DIR="/config/gpiommc"
# add_device(name, DI_pin, DO_pin, CLK_pin, CS_pin, mode)
add_device() {
local dir="$CONFIGFS_DIR/$1"
mkdir -p $dir
[ $? -eq 0 ] || return 1
echo $2 > $dir/gpio_data_in
[ $? -eq 0 ] || return 1
echo $3 > $dir/gpio_data_out
[ $? -eq 0 ] || return 1
echo $4 > $dir/gpio_clock
[ $? -eq 0 ] || return 1
echo $5 > $dir/gpio_chipselect
[ $? -eq 0 ] || return 1
echo $6 > $dir/spi_mode
[ $? -eq 0 ] || return 1
# XXX We have more config options available. Use defaults for now.
echo 1 > $dir/register
[ $? -eq 0 ] || return 1
return 0
}
# remove_device(name)
remove_device() {
local dir="$CONFIGFS_DIR/$1"
rmdir $dir
}
mount_configfs() {
# FIXME: This should probably be done somewhere else.
mount | grep configfs
if [ $? -eq 0 ]; then
# already mounted
return 0
fi
mkdir -p /config
[ $? -eq 0 ] || return 1
mount configfs -t configfs /config
[ $? -eq 0 ] || return 1
return 0
}
start_service() {
local section="$1"
config_get "name" "$section" "name"
config_get "DI_pin" "$section" "DI_pin"
config_get "DO_pin" "$section" "DO_pin"
config_get "CLK_pin" "$section" "CLK_pin"
config_get "CS_pin" "$section" "CS_pin"
config_get "mode" "$section" "mode"
config_get_bool "enabled" "$section" "enabled" '1'
[ "$enabled" -gt 0 ] && add_device "$name" $DI_pin $DO_pin $CLK_pin $CS_pin $mode &
}
stop_service() {
local section="$1"
config_get "name" "$section" "name"
remove_device "$name"
}
start() {
# Make sure configfs is mounted
mount_configfs
[ $? -eq 0 ] || return 1
config_load "mmc_over_gpio"
config_foreach start_service "mmc_over_gpio"
}
stop() {
config_load "mmc_over_gpio"
config_foreach stop_service "mmc_over_gpio"
}

View File

@@ -0,0 +1,47 @@
# Copyright (C) 2009-2012 OpenWrt.org
# All rights reserved.
include $(TOPDIR)/rules.mk
PKG_NAME:=mountd
PKG_VERSION:=0.1
PKG_RELEASE:=6
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
PKG_MD5SUM:=b77253ee4321d24d200fffc4f7ca3d15
PKG_MAINTAINER:=John Crispin <blogic@openwrt.org>
include $(INCLUDE_DIR)/package.mk
define Package/mountd
SECTION:=utils
CATEGORY:=Utilities
TITLE:=OpenWrt automount daemon
DEPENDS:=@USB_SUPPORT +uci +kmod-usb-storage +kmod-fs-autofs4
URL:=http://www.openwrt.org
endef
define Package/mountd/description
openwrt automount daemon
endef
define Package/mountd/conffiles
/etc/config/mountd
endef
define Build/Compile
$(TARGET_CONFIGURE_OPTS) \
CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include -I$(PKG_BUILD_DIR)" \
LDFLAGS="$(TARGET_LDFLAGS)" \
$(MAKE) -C $(PKG_BUILD_DIR)
endef
define Package/mountd/install
$(INSTALL_DIR) $(1)/sbin/ $(1)/etc/config/ $(1)/etc/init.d/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/mountd $(1)/sbin/
$(INSTALL_DATA) ./files/mountd.config $(1)/etc/config/mountd
$(INSTALL_BIN) ./files/mountd.init $(1)/etc/init.d/mountd
endef
$(eval $(call BuildPackage,mountd))

View File

@@ -0,0 +1,3 @@
config mountd mountd
option timeout 60
option path /tmp/mounts/

View File

@@ -0,0 +1,19 @@
#!/bin/sh /etc/rc.common
START=80
SERVICE_DAEMONIZE=1
SERVICE_WRITE_PID=1
SERVICE_PID_FILE=/var/run/mountd.pid
MOUNTD_BIN=/sbin/mountd
start()
{
service_start $MOUNTD_BIN -f
}
stop()
{
service_stop $MOUNTD_BIN
}

View File

@@ -0,0 +1,27 @@
---
lib/uci.c | 2 +-
lib/ucix.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
--- a/lib/uci.c
+++ b/lib/uci.c
@@ -28,7 +28,7 @@ struct uci_package *p = NULL;
struct uci_context* uci_init(char *config_file)
{
struct uci_context *ctx = uci_alloc_context();
- uci_add_history_path(ctx, "/var/state");
+ uci_add_delta_path(ctx, "/var/state");
if(uci_load(ctx, config_file, &p) != UCI_OK)
{
log_printf("/etc/config/%s is missing or corrupt\n", config_file);
--- a/lib/ucix.c
+++ b/lib/ucix.c
@@ -18,7 +18,7 @@ static inline int ucix_get_ptr(struct uc
struct uci_context* ucix_init(const char *config_file)
{
struct uci_context *ctx = uci_alloc_context();
- uci_add_history_path(ctx, "/var/state");
+ uci_add_delta_path(ctx, "/var/state");
if(uci_load(ctx, config_file, NULL) != UCI_OK)
{
printf("%s/%s is missing or corrupt\n", ctx->savedir, config_file);

View File

@@ -0,0 +1,32 @@
--- a/lib/autofs.c
+++ b/lib/autofs.c
@@ -140,6 +140,7 @@ static int fullread(void *ptr, size_t le
static int autofs_in(union autofs_v5_packet_union *pkt)
{
+ int res;
struct pollfd fds[1];
fds[0].fd = fdout;
@@ -147,15 +148,19 @@ static int autofs_in(union autofs_v5_pac
while(1)
{
- if(poll(fds, 2, 1000) == -1)
+ res = poll(fds, 1, -1);
+
+ if (res == -1)
{
if (errno == EINTR)
continue;
log_printf("failed while trying to read packet from kernel\n");
return -1;
}
- if(fds[0].revents & POLLIN)
+ else if ((res > 0) && (fds[0].revents & POLLIN))
+ {
return fullread(pkt, sizeof(*pkt));
+ }
}
}

View File

@@ -0,0 +1,85 @@
diff -ruN mountd-0.1.orig/include/fs.h mountd-0.1/include/fs.h
--- mountd-0.1.orig/include/fs.h 2009-10-02 22:57:04.000000000 +0200
+++ mountd-0.1/include/fs.h 2012-07-08 18:42:32.000000000 +0200
@@ -7,5 +7,6 @@
#define EFI 7
#define NTFS 8
#define EXTENDED 9
+#define EXT4 10
int detect_fs(char *device);
diff -ruN mountd-0.1.orig/lib/fs.c mountd-0.1/lib/fs.c
--- mountd-0.1.orig/lib/fs.c 2009-10-02 23:26:22.000000000 +0200
+++ mountd-0.1/lib/fs.c 2012-07-08 19:28:08.000000000 +0200
@@ -91,9 +91,14 @@
goto out;
if(get_le_short(buffer + 56) == 0xEF53)
{
- if((get_le_long(buffer + 96) & 0x0008)
- || (get_le_long(buffer + 92) & 0x0004))
- ret = EXT3;
+ if(get_le_long(buffer + 92) & 0x0004)
+ {
+ if ((get_le_long(buffer + 96) < 0x0000040)
+ && (get_le_long(buffer + 100) < 0x0000008))
+ ret = EXT3;
+ else
+ ret = EXT4;
+ }
else
ret = EXT2;
}
diff -ruN mountd-0.1.orig/lib/mount.c mountd-0.1/lib/mount.c
--- mountd-0.1.orig/lib/mount.c 2009-10-03 12:54:57.000000000 +0200
+++ mountd-0.1/lib/mount.c 2012-07-08 19:04:29.000000000 +0200
@@ -53,7 +53,10 @@
"EXT3",
"FAT",
"HFSPLUS",
- "NTFS"
+ "",
+ "NTFS",
+ "",
+ "EXT4"
};
#define MAX_MOUNTED 32
@@ -93,7 +96,7 @@
ucix_add_option(ctx, mountd, q->serial, "rev", q->rev);
snprintf(t, 64, "size%d", atoi(&q->dev[3]));
ucix_add_option(ctx, mountd, q->serial, t, q->size);
- if(q->fs > MBR && q->fs <= NTFS)
+ if(q->fs > MBR && q->fs <= EXT4)
{
snprintf(t, 64, "fs%d", atoi(&q->dev[3]));
ucix_add_option(ctx, mountd, q->serial, t, fs_names[q->fs]);
@@ -131,7 +134,7 @@
{
struct mount *mount;
char tmp[64], tmp2[64];
- if(fs <= MBR || fs > NTFS)
+ if(fs <= MBR || fs > EXT4)
return;
mount = malloc(sizeof(struct mount));
INIT_LIST_HEAD(&mount->list);
@@ -147,7 +150,7 @@
mount->mounted = 0;
mount->fs = fs;
list_add(&mount->list, &mounts);
- if((!mount->ignore) && (mount->fs > MBR) && (mount->fs <= NTFS))
+ if((!mount->ignore) && (mount->fs > MBR) && (mount->fs <= EXT4))
{
log_printf("new mount : %s -> %s (%s)\n", name, dev, fs_names[mount->fs]);
snprintf(tmp, 64, "%s%s", uci_path, name);
@@ -226,6 +229,11 @@
log_printf("mount -t vfat -o rw,uid=1000,gid=1000 /dev/%s %s", mount->dev, tmp);
ret = system_printf("mount -t vfat -o rw,uid=1000,gid=1000 /dev/%s %s", mount->dev, tmp);
}
+ if(mount->fs == EXT4)
+ {
+ log_printf("mount -t ext4 -o rw,defaults /dev/%s %s", mount->dev, tmp);
+ ret = system_printf("mount -t ext4 -o rw,defaults /dev/%s %s", mount->dev, tmp);
+ }
if(mount->fs == EXT3)
{
log_printf("mount -t ext3 -o rw,defaults /dev/%s %s", mount->dev, tmp);

View File

@@ -0,0 +1,13 @@
--- a/main.c
+++ b/main.c
@@ -13,7 +13,9 @@
int main(int argc, char *argv[])
{
- daemon(0,0);
+ if ((argc < 2) || strcmp(argv[1], "-f"))
+ daemon(0,0);
+
daemonize = 1;
log_start();
log_printf("Starting OpenWrt (auto)mountd V1\n");

View File

@@ -0,0 +1,53 @@
#
# Copyright (C) 2006-2012 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)/kernel.mk
PKG_NAME:=mtd
PKG_RELEASE:=20
PKG_BUILD_DIR := $(KERNEL_BUILD_DIR)/$(PKG_NAME)
STAMP_PREPARED := $(STAMP_PREPARED)_$(call confvar,CONFIG_MTD_REDBOOT_PARTS)
PKG_LICENSE:=GPLv2 GPLv2+
PKG_LICENSE_FILES:=
include $(INCLUDE_DIR)/package.mk
define Package/mtd
SECTION:=utils
CATEGORY:=Base system
TITLE:=Update utility for trx firmware images
endef
define Package/mtd/description
This package contains an utility useful to upgrade from other firmware or
older OpenWrt releases.
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
target=$(firstword $(subst -, ,$(BOARD)))
MAKE_FLAGS += TARGET="$(target)"
TARGET_CFLAGS := $(TARGET_CFLAGS) -Dtarget_$(target)=1 -Wall
ifdef CONFIG_MTD_REDBOOT_PARTS
MAKE_FLAGS += FIS_SUPPORT=1
TARGET_CFLAGS += -DFIS_SUPPORT=1
endif
define Package/mtd/install
$(INSTALL_DIR) $(1)/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/mtd $(1)/sbin/
endef
$(eval $(call BuildPackage,mtd))

View File

@@ -0,0 +1,18 @@
CC = gcc
CFLAGS += -Wall
obj = mtd.o jffs2.o crc32.o
obj.seama = seama.o md5.o
obj.ar71xx = trx.o
obj.brcm = trx.o
obj.brcm47xx = $(obj.brcm)
obj.brcm63xx = imagetag.o
obj.ramips = $(obj.seama)
ifdef FIS_SUPPORT
obj += fis.o
endif
mtd: $(obj) $(obj.$(TARGET))
clean:
rm -f *.o jffs2

View File

@@ -0,0 +1,95 @@
/*
* COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or
* code or tables extracted from it, as desired without restriction.
*
* First, the polynomial itself and its table of feedback terms. The
* polynomial is
* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0
*
* Note that we take it "backwards" and put the highest-order term in
* the lowest-order bit. The X^32 term is "implied"; the LSB is the
* X^31 term, etc. The X^0 term (usually shown as "+1") results in
* the MSB being 1
*
* Note that the usual hardware shift register implementation, which
* is what we're using (we're merely optimizing it by doing eight-bit
* chunks at a time) shifts bits into the lowest-order term. In our
* implementation, that means shifting towards the right. Why do we
* do it this way? Because the calculated CRC must be transmitted in
* order from highest-order term to lowest-order term. UARTs transmit
* characters in order from LSB to MSB. By storing the CRC this way
* we hand it to the UART in the order low-byte to high-byte; the UART
* sends each low-bit to hight-bit; and the result is transmission bit
* by bit from highest- to lowest-order term without requiring any bit
* shuffling on our part. Reception works similarly
*
* The feedback terms table consists of 256, 32-bit entries. Notes
*
* The table can be generated at runtime if desired; code to do so
* is shown later. It might not be obvious, but the feedback
* terms simply represent the results of eight shift/xor opera
* tions for all combinations of data and CRC register values
*
* The values must be right-shifted by eight bits by the "updcrc
* logic; the shift must be unsigned (bring in zeroes). On some
* hardware you could probably optimize the shift in assembler by
* using byte-swap instructions
* polynomial $edb88320
*/
#include <stdint.h>
const uint32_t crc32_table[256] = {
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
0x2d02ef8dL
};

View File

@@ -0,0 +1,26 @@
#ifndef CRC32_H
#define CRC32_H
#include <stdint.h>
extern const uint32_t crc32_table[256];
/* Return a 32-bit CRC of the contents of the buffer. */
static inline uint32_t
crc32(uint32_t val, const void *ss, int len)
{
const unsigned char *s = ss;
while (--len >= 0)
val = crc32_table[(val ^ *s++) & 0xff] ^ (val >> 8);
return val;
}
static inline unsigned int crc32buf(char *buf, size_t len)
{
return crc32(0xFFFFFFFF, buf, len);
}
#endif

View File

@@ -0,0 +1,262 @@
/*
* FIS table updating code for mtd
*
* Copyright (C) 2009 Felix Fietkau <nbd@openwrt.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
*
* 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 <sys/mman.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include "crc32.h"
#include "mtd.h"
#include "fis.h"
struct fis_image_hdr {
unsigned char name[16];
uint32_t flash_base;
uint32_t mem_base;
uint32_t size;
uint32_t entry_point;
uint32_t data_length;
} __attribute__((packed));
struct fis_image_crc {
uint32_t desc;
uint32_t file;
} __attribute__((packed));
struct fis_image_desc {
struct fis_image_hdr hdr;
char _pad[256 - sizeof(struct fis_image_hdr) - sizeof(struct fis_image_crc)];
struct fis_image_crc crc;
} __attribute__((packed));
static int fis_fd = -1;
static struct fis_image_desc *fis_desc;
static int fis_erasesize = 0;
static void
fis_close(void)
{
if (fis_desc)
munmap(fis_desc, fis_erasesize);
if (fis_fd >= 0)
close(fis_fd);
fis_fd = -1;
fis_desc = NULL;
}
static struct fis_image_desc *
fis_open(void)
{
struct fis_image_desc *desc;
if (fis_fd >= 0)
fis_close();
fis_fd = mtd_check_open("FIS directory");
if (fis_fd < 0)
goto error;
close(fis_fd);
fis_fd = mtd_open("FIS directory", true);
if (fis_fd < 0)
goto error;
fis_erasesize = erasesize;
desc = mmap(NULL, erasesize, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_LOCKED, fis_fd, 0);
if (desc == MAP_FAILED)
goto error;
fis_desc = desc;
return desc;
error:
fis_close();
return NULL;
}
int
fis_validate(struct fis_part *old, int n_old, struct fis_part *new, int n_new)
{
struct fis_image_desc *desc;
void *end;
int found = 0;
int i;
desc = fis_open();
if (!desc)
return -1;
for (i = 0; i < n_new - 1; i++) {
if (!new[i].size) {
fprintf(stderr, "FIS error: only the last partition can detect the size automatically\n");
i = -1;
goto done;
}
}
end = desc;
end = (char *) end + fis_erasesize;
while ((void *) desc < end) {
if (!desc->hdr.name[0] || (desc->hdr.name[0] == 0xff))
break;
for (i = 0; i < n_old; i++) {
if (!strncmp((char *) desc->hdr.name, (char *) old[i].name, sizeof(desc->hdr.name))) {
found++;
goto next;
}
}
next:
desc++;
continue;
}
if (found == n_old)
i = 1;
else
i = -1;
done:
fis_close();
return i;
}
int
fis_remap(struct fis_part *old, int n_old, struct fis_part *new, int n_new)
{
struct fis_image_desc *fisdir = NULL;
struct fis_image_desc *redboot = NULL;
struct fis_image_desc *first = NULL;
struct fis_image_desc *last = NULL;
struct fis_image_desc *first_fb = NULL;
struct fis_image_desc *last_fb = NULL;
struct fis_image_desc *desc;
struct fis_part *part;
uint32_t offset = 0, size = 0;
char *start, *end, *tmp;
int i;
desc = fis_open();
if (!desc)
return -1;
if (!quiet)
fprintf(stderr, "Updating FIS table... \n");
start = (char *) desc;
end = (char *) desc + fis_erasesize;
while ((char *) desc < end) {
if (!desc->hdr.name[0] || (desc->hdr.name[0] == 0xff))
break;
if (!strcmp((char *) desc->hdr.name, "FIS directory"))
fisdir = desc;
if (!strcmp((char *) desc->hdr.name, "RedBoot"))
redboot = desc;
/* update max offset */
if (offset < desc->hdr.flash_base)
offset = desc->hdr.flash_base;
for (i = 0; i < n_old; i++) {
if (!strncmp((char *) desc->hdr.name, (char *) old[i].name, sizeof(desc->hdr.name))) {
last = desc;
if (!first)
first = desc;
break;
}
}
desc++;
}
desc--;
first_fb = first;
last_fb = last;
if (first_fb->hdr.flash_base > last_fb->hdr.flash_base) {
first_fb = last;
last_fb = first;
}
/* determine size of available space */
desc = (struct fis_image_desc *) start;
while ((char *) desc < end) {
if (!desc->hdr.name[0] || (desc->hdr.name[0] == 0xff))
break;
if (desc->hdr.flash_base > last_fb->hdr.flash_base &&
desc->hdr.flash_base < offset)
offset = desc->hdr.flash_base;
desc++;
}
desc--;
size = offset - first_fb->hdr.flash_base;
#ifdef notyet
desc = first - 1;
if (redboot && (desc >= redboot)) {
if (first->hdr.flash_base - desc->hdr.size > desc->hdr.flash_base) {
int delta = first->hdr.flash_base - desc->hdr.size - desc->hdr.flash_base;
offset -= delta;
size += delta;
}
}
#endif
last++;
desc = first + n_new;
offset = first_fb->hdr.flash_base;
if (desc != last) {
if (desc > last)
tmp = (char *) desc;
else
tmp = (char *) last;
memmove(desc, last, end - tmp);
if (desc < last) {
tmp = end - (last - desc) * sizeof(struct fis_image_desc);
memset(tmp, 0xff, tmp - end);
}
}
for (part = new, desc = first; desc < first + n_new; desc++, part++) {
memset(desc, 0, sizeof(struct fis_image_desc));
memcpy(desc->hdr.name, part->name, sizeof(desc->hdr.name));
desc->crc.desc = 0;
desc->crc.file = 0;
desc->hdr.flash_base = offset;
desc->hdr.mem_base = part->loadaddr;
desc->hdr.entry_point = part->loadaddr;
desc->hdr.size = (part->size > 0) ? part->size : size;
desc->hdr.data_length = desc->hdr.size;
offset += desc->hdr.size;
size -= desc->hdr.size;
}
msync(fis_desc, fis_erasesize, MS_SYNC|MS_INVALIDATE);
fis_close();
return 0;
}

View File

@@ -0,0 +1,14 @@
#ifndef __FIS_H
#define __FIS_H
struct fis_part {
unsigned char name[16];
uint32_t offset;
uint32_t loadaddr;
uint32_t size;
};
int fis_validate(struct fis_part *old, int n_old, struct fis_part *new, int n_new);
int fis_remap(struct fis_part *old, int n_old, struct fis_part *new, int n_new);
#endif

View File

@@ -0,0 +1,316 @@
/*
* imagetag.c
*
* Copyright (C) 2005 Mike Baker
* Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
* Copyrigth (C) 2010 Daniel Dickinson <openwrt@cshore.neomailbox.net>
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <mtd/mtd-user.h>
#include <linux/bcm963xx_tag.h>
#include "mtd.h"
#include "crc32.h"
ssize_t pread(int fd, void *buf, size_t count, off_t offset);
ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
#define CRC_START 0xFFFFFFFF
static uint32_t strntoul(char *str, char **endptr, int base, size_t len) {
char *newstr;
uint32_t res = 0;
newstr = calloc(len + 1, sizeof(char));
if (newstr) {
strncpy(newstr, str, len);
res = strtoul(newstr, endptr, base);
free(newstr);
}
return res;
}
uint32_t compute_crc32(uint32_t crc, off_t start, size_t compute_len, int fd)
{
uint8_t readbuf[1024];
ssize_t res;
off_t offset = start;
/* Read a buffer's worth of bytes */
while (fd && (compute_len >= sizeof(readbuf))) {
res = pread(fd, readbuf, sizeof(readbuf), offset);
crc = crc32(crc, readbuf, res);
compute_len = compute_len - res;
offset += res;
}
/* Less than buffer-size bytes remains, read compute_len bytes */
if (fd && (compute_len > 0)) {
res = pread(fd, readbuf, compute_len, offset);
crc = crc32(crc, readbuf, res);
}
return crc;
}
int
trx_fixup(int fd, const char *name)
{
struct mtd_info_user mtdInfo;
unsigned long len;
void *ptr, *scan;
int bfd;
struct bcm_tag *tag;
ssize_t res;
uint32_t cfelen, imagelen, imagestart, rootfslen;
uint32_t imagecrc, rootfscrc, headercrc;
uint32_t offset = 0;
cfelen = imagelen = imagestart = imagecrc = rootfscrc = headercrc = rootfslen = 0;
if (ioctl(fd, MEMGETINFO, &mtdInfo) < 0) {
fprintf(stderr, "Failed to get mtd info\n");
goto err;
}
len = mtdInfo.size;
if (mtdInfo.size <= 0) {
fprintf(stderr, "Invalid MTD device size\n");
goto err;
}
bfd = mtd_open(name, true);
ptr = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_SHARED, bfd, 0);
if (!ptr || (ptr == (void *) -1)) {
perror("mmap");
goto err1;
}
tag = (struct bcm_tag *) (ptr);
cfelen = strntoul(&tag->cfe_length[0], NULL, 10, IMAGE_LEN);
if (cfelen) {
fprintf(stderr, "Non-zero CFE length. This is currently unsupported.\n");
exit(1);
}
headercrc = compute_crc32(CRC_START, offset, offsetof(struct bcm_tag, header_crc), fd);
if (headercrc != *(uint32_t *)(&tag->header_crc)) {
fprintf(stderr, "Tag verify failed. This may not be a valid image.\n");
exit(1);
}
sprintf(&tag->root_length[0], "%u", 0);
strncpy(&tag->total_length[0], &tag->kernel_length[0], IMAGE_LEN);
imagestart = sizeof(tag);
memcpy(&tag->image_crc, &tag->kernel_crc, sizeof(uint32_t));
memcpy(&tag->fskernel_crc, &tag->kernel_crc, sizeof(uint32_t));
rootfscrc = CRC_START;
memcpy(&tag->rootfs_crc, &rootfscrc, sizeof(uint32_t));
headercrc = crc32(CRC_START, tag, offsetof(struct bcm_tag, header_crc));
memcpy(&tag->header_crc, &headercrc, sizeof(uint32_t));
msync(ptr, sizeof(struct bcm_tag), MS_SYNC|MS_INVALIDATE);
munmap(ptr, len);
close(bfd);
return 0;
err1:
close(bfd);
err:
fprintf(stderr, "Error fixing up imagetag header\n");
return -1;
}
int
trx_check(int imagefd, const char *mtd, char *buf, int *len)
{
struct bcm_tag *tag = (const struct bcm_tag *) buf;
int fd;
uint32_t headerCRC;
uint32_t imageLen;
if (strcmp(mtd, "linux") != 0)
return 1;
*len = read(imagefd, buf, sizeof(struct bcm_tag));
if (*len < sizeof(struct bcm_tag)) {
fprintf(stdout, "Could not get image header, file too small (%d bytes)\n", *len);
return 0;
}
headerCRC = crc32buf(buf, offsetof(struct bcm_tag, header_crc));
if (*(uint32_t *)(&tag->header_crc) != headerCRC) {
if (quiet < 2) {
fprintf(stderr, "Bad header CRC got %08x, calculated %08x\n",
*(uint32_t *)(&tag->header_crc), headerCRC);
fprintf(stderr, "This is not the correct file format; refusing to flash.\n"
"Please specify the correct file or use -f to force.\n");
}
return 0;
}
/* check if image fits to mtd device */
fd = mtd_check_open(mtd);
if(fd < 0) {
fprintf(stderr, "Could not open mtd device: %s\n", mtd);
exit(1);
}
imageLen = strntoul(&tag->total_length[0], NULL, 10, IMAGE_LEN);
if(mtdsize < imageLen) {
fprintf(stderr, "Image too big for partition: %s\n", mtd);
close(fd);
return 0;
}
close(fd);
return 1;
}
int
mtd_fixtrx(const char *mtd, size_t offset)
{
int fd;
struct bcm_tag *tag;
char *buf;
ssize_t res;
size_t block_offset;
uint32_t cfelen, imagelen, imagestart, rootfslen;
uint32_t imagecrc, rootfscrc, headercrc;
cfelen = imagelen = imagestart = imagecrc = rootfscrc = headercrc = rootfslen = 0;
if (quiet < 2)
fprintf(stderr, "Trying to fix trx header in %s at 0x%x...\n", mtd, offset);
block_offset = offset & ~(erasesize - 1);
offset -= block_offset;
fd = mtd_check_open(mtd);
if(fd < 0) {
fprintf(stderr, "Could not open mtd device: %s\n", mtd);
exit(1);
}
if (block_offset + erasesize > mtdsize) {
fprintf(stderr, "Offset too large, device size 0x%x\n", mtdsize);
exit(1);
}
buf = malloc(erasesize);
if (!buf) {
perror("malloc");
exit(1);
}
res = pread(fd, buf, erasesize, block_offset);
if (res != erasesize) {
perror("pread");
exit(1);
}
tag = (struct bcm_tag *) (buf + offset);
cfelen = strntoul(tag->cfe_length, NULL, 10, IMAGE_LEN);
if (cfelen) {
fprintf(stderr, "Non-zero CFE length. This is currently unsupported.\n");
exit(1);
}
if (quiet < 2) {
fprintf(stderr, "Verifying we actually have an imagetag.\n");
}
headercrc = compute_crc32(CRC_START, offset, offsetof(struct bcm_tag, header_crc), fd);
if (headercrc != *(uint32_t *)(&tag->header_crc)) {
fprintf(stderr, "Tag verify failed. This may not be a valid image.\n");
exit(1);
}
if (quiet < 2) {
fprintf(stderr, "Checking current fixed status.\n");
}
rootfslen = strntoul(&tag->root_length[0], NULL, 10, IMAGE_LEN);
if (rootfslen == 0) {
if (quiet < 2)
fprintf(stderr, "Header already fixed, exiting\n");
close(fd);
return 0;
}
if (quiet < 2) {
fprintf(stderr, "Setting root length to 0.\n");
}
sprintf(&tag->root_length[0], "%u", 0);
strncpy(&tag->total_length[0], &tag->kernel_length[0], IMAGE_LEN);
if (quiet < 2) {
fprintf(stderr, "Recalculating CRCs.\n");
}
imagestart = sizeof(tag);
memcpy(&tag->image_crc, &tag->kernel_crc, sizeof(uint32_t));
memcpy(&tag->fskernel_crc, &tag->kernel_crc, sizeof(uint32_t));
rootfscrc = CRC_START;
memcpy(&tag->rootfs_crc, &rootfscrc, sizeof(uint32_t));
headercrc = crc32(CRC_START, tag, offsetof(struct bcm_tag, header_crc));
memcpy(&tag->header_crc, &headercrc, sizeof(uint32_t));
if (quiet < 2) {
fprintf(stderr, "Erasing imagetag block\n");
}
if (mtd_erase_block(fd, block_offset)) {
fprintf(stderr, "Can't erase block at 0x%x (%s)\n", block_offset, strerror(errno));
exit(1);
}
if (quiet < 2) {
fprintf(stderr, "New image crc32: 0x%x, rewriting block\n",
*(uint32_t *)(&tag->image_crc));
fprintf(stderr, "New header crc32: 0x%x, rewriting block\n", headercrc);
}
if (pwrite(fd, buf, erasesize, block_offset) != erasesize) {
fprintf(stderr, "Error writing block (%s)\n", strerror(errno));
exit(1);
}
if (quiet < 2)
fprintf(stderr, "Done.\n");
close (fd);
sync();
return 0;
}

View File

@@ -0,0 +1,357 @@
/*
* jffs2 on-disk structure generator for mtd
*
* Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
*
* 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.
* Based on:
* JFFS2 -- Journalling Flash File System, Version 2.
* Copyright © 2001-2007 Red Hat, Inc.
* Created by David Woodhouse <dwmw2@infradead.org>
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <stdint.h>
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#include <unistd.h>
#include <endian.h>
#include "jffs2.h"
#include "crc32.h"
#include "mtd.h"
#define PAD(x) (((x)+3)&~3)
#if BYTE_ORDER == BIG_ENDIAN
# define CLEANMARKER "\x19\x85\x20\x03\x00\x00\x00\x0c\xf0\x60\xdc\x98"
#else
# define CLEANMARKER "\x85\x19\x03\x20\x0c\x00\x00\x00\xb1\xb0\x1e\xe4"
#endif
static int last_ino = 0;
static int last_version = 0;
static char *buf = NULL;
static int ofs = 0;
static int outfd = -1;
static int mtdofs = 0;
static int target_ino = 0;
static void prep_eraseblock(void);
static void pad(int size)
{
if ((ofs % size == 0) && (ofs < erasesize))
return;
if (ofs < erasesize) {
memset(buf + ofs, 0xff, (size - (ofs % size)));
ofs += (size - (ofs % size));
}
ofs = ofs % erasesize;
if (ofs == 0) {
mtd_erase_block(outfd, mtdofs);
write(outfd, buf, erasesize);
mtdofs += erasesize;
}
}
static inline int rbytes(void)
{
return erasesize - (ofs % erasesize);
}
static inline void add_data(char *ptr, int len)
{
if (ofs + len > erasesize) {
pad(erasesize);
prep_eraseblock();
}
memcpy(buf + ofs, ptr, len);
ofs += len;
}
static void prep_eraseblock(void)
{
if (ofs > 0)
return;
add_data(CLEANMARKER, sizeof(CLEANMARKER) - 1);
}
static int add_dirent(const char *name, const char type, int parent)
{
struct jffs2_raw_dirent *de;
if (ofs - erasesize < sizeof(struct jffs2_raw_dirent) + strlen(name))
pad(erasesize);
prep_eraseblock();
last_ino++;
memset(buf + ofs, 0, sizeof(struct jffs2_raw_dirent));
de = (struct jffs2_raw_dirent *) (buf + ofs);
de->magic = JFFS2_MAGIC_BITMASK;
de->nodetype = JFFS2_NODETYPE_DIRENT;
de->type = type;
de->name_crc = crc32(0, name, strlen(name));
de->ino = last_ino++;
de->pino = parent;
de->totlen = sizeof(*de) + strlen(name);
de->hdr_crc = crc32(0, (void *) de, sizeof(struct jffs2_unknown_node) - 4);
de->version = last_version++;
de->mctime = 0;
de->nsize = strlen(name);
de->node_crc = crc32(0, (void *) de, sizeof(*de) - 8);
memcpy(de->name, name, strlen(name));
ofs += sizeof(struct jffs2_raw_dirent) + de->nsize;
pad(4);
return de->ino;
}
static int add_dir(const char *name, int parent)
{
struct jffs2_raw_inode ri;
int inode;
inode = add_dirent(name, IFTODT(S_IFDIR), parent);
if (rbytes() < sizeof(ri))
pad(erasesize);
prep_eraseblock();
memset(&ri, 0, sizeof(ri));
ri.magic = JFFS2_MAGIC_BITMASK;
ri.nodetype = JFFS2_NODETYPE_INODE;
ri.totlen = sizeof(ri);
ri.hdr_crc = crc32(0, &ri, sizeof(struct jffs2_unknown_node) - 4);
ri.ino = inode;
ri.mode = S_IFDIR | 0755;
ri.uid = ri.gid = 0;
ri.atime = ri.ctime = ri.mtime = 0;
ri.isize = ri.csize = ri.dsize = 0;
ri.version = 1;
ri.node_crc = crc32(0, &ri, sizeof(ri) - 8);
ri.data_crc = 0;
add_data((char *) &ri, sizeof(ri));
pad(4);
return inode;
}
static void add_file(const char *name, int parent)
{
int inode, f_offset = 0, fd;
struct jffs2_raw_inode ri;
struct stat st;
char wbuf[4096];
const char *fname;
if (stat(name, &st)) {
fprintf(stderr, "File %s does not exist\n", name);
return;
}
fname = strrchr(name, '/');
if (fname)
fname++;
else
fname = name;
inode = add_dirent(fname, IFTODT(S_IFREG), parent);
memset(&ri, 0, sizeof(ri));
ri.magic = JFFS2_MAGIC_BITMASK;
ri.nodetype = JFFS2_NODETYPE_INODE;
ri.ino = inode;
ri.mode = st.st_mode;
ri.uid = ri.gid = 0;
ri.atime = st.st_atime;
ri.ctime = st.st_ctime;
ri.mtime = st.st_mtime;
ri.isize = st.st_size;
ri.compr = 0;
ri.usercompr = 0;
fd = open(name, 0);
if (fd < 0) {
fprintf(stderr, "File %s does not exist\n", name);
return;
}
for (;;) {
int len = 0;
for (;;) {
len = rbytes() - sizeof(ri);
if (len > 128)
break;
pad(erasesize);
prep_eraseblock();
}
if (len > sizeof(wbuf))
len = sizeof(wbuf);
len = read(fd, wbuf, len);
if (len <= 0)
break;
ri.totlen = sizeof(ri) + len;
ri.hdr_crc = crc32(0, &ri, sizeof(struct jffs2_unknown_node) - 4);
ri.version = ++last_version;
ri.offset = f_offset;
ri.csize = ri.dsize = len;
ri.node_crc = crc32(0, &ri, sizeof(ri) - 8);
ri.data_crc = crc32(0, wbuf, len);
f_offset += len;
add_data((char *) &ri, sizeof(ri));
add_data(wbuf, len);
pad(4);
prep_eraseblock();
}
close(fd);
}
int mtd_replace_jffs2(const char *mtd, int fd, int ofs, const char *filename)
{
outfd = fd;
mtdofs = ofs;
buf = malloc(erasesize);
target_ino = 1;
if (!last_ino)
last_ino = 1;
add_file(filename, target_ino);
pad(erasesize);
/* add eof marker, pad to eraseblock size and write the data */
add_data(JFFS2_EOF, sizeof(JFFS2_EOF) - 1);
pad(erasesize);
free(buf);
return (mtdofs - ofs);
}
void mtd_parse_jffs2data(const char *buf, const char *dir)
{
struct jffs2_unknown_node *node = (struct jffs2_unknown_node *) buf;
unsigned int ofs = 0;
while (ofs < erasesize) {
node = (struct jffs2_unknown_node *) (buf + ofs);
if (node->magic != 0x1985)
break;
ofs += PAD(node->totlen);
if (node->nodetype == JFFS2_NODETYPE_DIRENT) {
struct jffs2_raw_dirent *de = (struct jffs2_raw_dirent *) node;
/* is this the right directory name and is it a subdirectory of / */
if (*dir && (de->pino == 1) && !strncmp((char *) de->name, dir, de->nsize))
target_ino = de->ino;
/* store the last inode and version numbers for adding extra files */
if (last_ino < de->ino)
last_ino = de->ino;
if (last_version < de->version)
last_version = de->version;
}
}
}
int mtd_write_jffs2(const char *mtd, const char *filename, const char *dir)
{
int err = -1, fdeof = 0;
outfd = mtd_check_open(mtd);
if (outfd < 0)
return -1;
if (quiet < 2)
fprintf(stderr, "Appending %s to jffs2 partition %s\n", filename, mtd);
buf = malloc(erasesize);
if (!buf) {
fprintf(stderr, "Out of memory!\n");
goto done;
}
if (!*dir)
target_ino = 1;
/* parse the structure of the jffs2 first
* locate the directory that the file is going to be placed in */
for(;;) {
struct jffs2_unknown_node *node = (struct jffs2_unknown_node *) buf;
if (read(outfd, buf, erasesize) != erasesize) {
fdeof = 1;
break;
}
mtdofs += erasesize;
if (node->magic == 0x8519) {
fprintf(stderr, "Error: wrong endianness filesystem\n");
goto done;
}
/* assume no magic == end of filesystem
* the filesystem will probably end with be32(0xdeadc0de) */
if (node->magic != 0x1985)
break;
mtd_parse_jffs2data(buf, dir);
}
if (fdeof) {
fprintf(stderr, "Error: No room for additional data\n");
goto done;
}
/* jump back one eraseblock */
mtdofs -= erasesize;
lseek(outfd, mtdofs, SEEK_SET);
ofs = 0;
if (!last_ino)
last_ino = 1;
if (!target_ino)
target_ino = add_dir(dir, 1);
add_file(filename, target_ino);
pad(erasesize);
/* add eof marker, pad to eraseblock size and write the data */
add_data(JFFS2_EOF, sizeof(JFFS2_EOF) - 1);
pad(erasesize);
err = 0;
if (trx_fixup) {
trx_fixup(outfd, mtd);
}
done:
close(outfd);
if (buf)
free(buf);
return err;
}

View File

@@ -0,0 +1,216 @@
/*
* JFFS2 -- Journalling Flash File System, Version 2.
*
* Copyright (C) 2001-2003 Red Hat, Inc.
*
* Created by David Woodhouse <dwmw2@infradead.org>
*
* For licensing information, see the file 'LICENCE' in the
* jffs2 directory.
*
*
*/
#ifndef __LINUX_JFFS2_H__
#define __LINUX_JFFS2_H__
#define JFFS2_SUPER_MAGIC 0x72b6
/* You must include something which defines the C99 uintXX_t types.
We don't do it from here because this file is used in too many
different environments. */
/* Values we may expect to find in the 'magic' field */
#define JFFS2_OLD_MAGIC_BITMASK 0x1984
#define JFFS2_MAGIC_BITMASK 0x1985
#define KSAMTIB_CIGAM_2SFFJ 0x8519 /* For detecting wrong-endian fs */
#define JFFS2_EMPTY_BITMASK 0xffff
#define JFFS2_DIRTY_BITMASK 0x0000
/* Summary node MAGIC marker */
#define JFFS2_SUM_MAGIC 0x02851885
/* We only allow a single char for length, and 0xFF is empty flash so
we don't want it confused with a real length. Hence max 254.
*/
#define JFFS2_MAX_NAME_LEN 254
/* How small can we sensibly write nodes? */
#define JFFS2_MIN_DATA_LEN 128
#define JFFS2_COMPR_NONE 0x00
#define JFFS2_COMPR_ZERO 0x01
#define JFFS2_COMPR_RTIME 0x02
#define JFFS2_COMPR_RUBINMIPS 0x03
#define JFFS2_COMPR_COPY 0x04
#define JFFS2_COMPR_DYNRUBIN 0x05
#define JFFS2_COMPR_ZLIB 0x06
/* Compatibility flags. */
#define JFFS2_COMPAT_MASK 0xc000 /* What do to if an unknown nodetype is found */
#define JFFS2_NODE_ACCURATE 0x2000
/* INCOMPAT: Fail to mount the filesystem */
#define JFFS2_FEATURE_INCOMPAT 0xc000
/* ROCOMPAT: Mount read-only */
#define JFFS2_FEATURE_ROCOMPAT 0x8000
/* RWCOMPAT_COPY: Mount read/write, and copy the node when it's GC'd */
#define JFFS2_FEATURE_RWCOMPAT_COPY 0x4000
/* RWCOMPAT_DELETE: Mount read/write, and delete the node when it's GC'd */
#define JFFS2_FEATURE_RWCOMPAT_DELETE 0x0000
#define JFFS2_NODETYPE_DIRENT (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 1)
#define JFFS2_NODETYPE_INODE (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 2)
#define JFFS2_NODETYPE_CLEANMARKER (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
#define JFFS2_NODETYPE_PADDING (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 4)
#define JFFS2_NODETYPE_SUMMARY (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 6)
#define JFFS2_NODETYPE_XATTR (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 8)
#define JFFS2_NODETYPE_XREF (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 9)
/* XATTR Related */
#define JFFS2_XPREFIX_USER 1 /* for "user." */
#define JFFS2_XPREFIX_SECURITY 2 /* for "security." */
#define JFFS2_XPREFIX_ACL_ACCESS 3 /* for "system.posix_acl_access" */
#define JFFS2_XPREFIX_ACL_DEFAULT 4 /* for "system.posix_acl_default" */
#define JFFS2_XPREFIX_TRUSTED 5 /* for "trusted.*" */
#define JFFS2_ACL_VERSION 0x0001
// Maybe later...
//#define JFFS2_NODETYPE_CHECKPOINT (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
//#define JFFS2_NODETYPE_OPTIONS (JFFS2_FEATURE_RWCOMPAT_COPY | JFFS2_NODE_ACCURATE | 4)
#define JFFS2_INO_FLAG_PREREAD 1 /* Do read_inode() for this one at
mount time, don't wait for it to
happen later */
#define JFFS2_INO_FLAG_USERCOMPR 2 /* User has requested a specific
compression type */
/* These can go once we've made sure we've caught all uses without
byteswapping */
typedef uint32_t jint32_t;
typedef uint32_t jmode_t;
typedef uint16_t jint16_t;
struct jffs2_unknown_node
{
/* All start like this */
jint16_t magic;
jint16_t nodetype;
jint32_t totlen; /* So we can skip over nodes we don't grok */
jint32_t hdr_crc;
};
struct jffs2_raw_dirent
{
jint16_t magic;
jint16_t nodetype; /* == JFFS2_NODETYPE_DIRENT */
jint32_t totlen;
jint32_t hdr_crc;
jint32_t pino;
jint32_t version;
jint32_t ino; /* == zero for unlink */
jint32_t mctime;
uint8_t nsize;
uint8_t type;
uint8_t unused[2];
jint32_t node_crc;
jint32_t name_crc;
uint8_t name[0];
};
/* The JFFS2 raw inode structure: Used for storage on physical media. */
/* The uid, gid, atime, mtime and ctime members could be longer, but
are left like this for space efficiency. If and when people decide
they really need them extended, it's simple enough to add support for
a new type of raw node.
*/
struct jffs2_raw_inode
{
jint16_t magic; /* A constant magic number. */
jint16_t nodetype; /* == JFFS2_NODETYPE_INODE */
jint32_t totlen; /* Total length of this node (inc data, etc.) */
jint32_t hdr_crc;
jint32_t ino; /* Inode number. */
jint32_t version; /* Version number. */
jmode_t mode; /* The file's type or mode. */
jint16_t uid; /* The file's owner. */
jint16_t gid; /* The file's group. */
jint32_t isize; /* Total resultant size of this inode (used for truncations) */
jint32_t atime; /* Last access time. */
jint32_t mtime; /* Last modification time. */
jint32_t ctime; /* Change time. */
jint32_t offset; /* Where to begin to write. */
jint32_t csize; /* (Compressed) data size */
jint32_t dsize; /* Size of the node's data. (after decompression) */
uint8_t compr; /* Compression algorithm used */
uint8_t usercompr; /* Compression algorithm requested by the user */
jint16_t flags; /* See JFFS2_INO_FLAG_* */
jint32_t data_crc; /* CRC for the (compressed) data. */
jint32_t node_crc; /* CRC for the raw inode (excluding data) */
uint8_t data[0];
};
struct jffs2_raw_xattr {
jint16_t magic;
jint16_t nodetype; /* = JFFS2_NODETYPE_XATTR */
jint32_t totlen;
jint32_t hdr_crc;
jint32_t xid; /* XATTR identifier number */
jint32_t version;
uint8_t xprefix;
uint8_t name_len;
jint16_t value_len;
jint32_t data_crc;
jint32_t node_crc;
uint8_t data[0];
} __attribute__((packed));
struct jffs2_raw_xref
{
jint16_t magic;
jint16_t nodetype; /* = JFFS2_NODETYPE_XREF */
jint32_t totlen;
jint32_t hdr_crc;
jint32_t ino; /* inode number */
jint32_t xid; /* XATTR identifier number */
jint32_t xseqno; /* xref sequencial number */
jint32_t node_crc;
} __attribute__((packed));
struct jffs2_raw_summary
{
jint16_t magic;
jint16_t nodetype; /* = JFFS2_NODETYPE_SUMMARY */
jint32_t totlen;
jint32_t hdr_crc;
jint32_t sum_num; /* number of sum entries*/
jint32_t cln_mkr; /* clean marker size, 0 = no cleanmarker */
jint32_t padded; /* sum of the size of padding nodes */
jint32_t sum_crc; /* summary information crc */
jint32_t node_crc; /* node crc */
jint32_t sum[0]; /* inode summary info */
};
union jffs2_node_union
{
struct jffs2_raw_inode i;
struct jffs2_raw_dirent d;
struct jffs2_raw_xattr x;
struct jffs2_raw_xref r;
struct jffs2_raw_summary s;
struct jffs2_unknown_node u;
};
/* Data payload for device nodes. */
union jffs2_device_node {
jint16_t old;
jint32_t new;
};
#endif /* __LINUX_JFFS2_H__ */

View File

@@ -0,0 +1,307 @@
/*
***********************************************************************
** md5.c -- the source code for MD5 routines **
** RSA Data Security, Inc. MD5 Message-Digest Algorithm **
** Created: 2/17/90 RLR **
** Revised: 1/91 SRD,AJ,BSK,JT Reference C ver., 7/10 constant corr. **
***********************************************************************
*/
/*
***********************************************************************
** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
** **
** License to copy and use this software is granted provided that **
** it is identified as the "RSA Data Security, Inc. MD5 Message- **
** Digest Algorithm" in all material mentioning or referencing this **
** software or this function. **
** **
** License is also granted to make and use derivative works **
** provided that such works are identified as "derived from the RSA **
** Data Security, Inc. MD5 Message-Digest Algorithm" in all **
** material mentioning or referencing the derived work. **
** **
** RSA Data Security, Inc. makes no representations concerning **
** either the merchantability of this software or the suitability **
** of this software for any particular purpose. It is provided "as **
** is" without express or implied warranty of any kind. **
** **
** These notices must be retained in any copies of any part of this **
** documentation and/or software. **
***********************************************************************
*/
#include <string.h>
#include "md5.h"
/*
***********************************************************************
** Message-digest routines: **
** To form the message digest for a message M **
** (1) Initialize a context buffer mdContext using MD5_Init **
** (2) Call MD5_Update on mdContext and M **
** (3) Call MD5_Final on mdContext **
** The message digest is now in mdContext->digest[0...15] **
***********************************************************************
*/
/* forward declaration */
static void Transform ();
static unsigned char PADDING[64] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
/* F, G, H and I are basic MD5 functions */
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | (~z)))
/* ROTATE_LEFT rotates x left n bits */
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */
/* Rotation is separate from addition to prevent recomputation */
#define FF(a, b, c, d, x, s, ac) \
{(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) \
{(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) \
{(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) \
{(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#ifdef __STDC__
#define UL(x) x##U
#else
#define UL(x) x
#endif
/* The routine MD5_Init initializes the message-digest context
mdContext. All fields are set to zero.
*/
void MD5_Init (mdContext)
MD5_CTX *mdContext;
{
mdContext->i[0] = mdContext->i[1] = (UINT4)0;
/* Load magic initialization constants.
*/
mdContext->buf[0] = (UINT4)0x67452301;
mdContext->buf[1] = (UINT4)0xefcdab89;
mdContext->buf[2] = (UINT4)0x98badcfe;
mdContext->buf[3] = (UINT4)0x10325476;
}
/* The routine MD5Update updates the message-digest context to
account for the presence of each of the characters inBuf[0..inLen-1]
in the message whose digest is being computed.
*/
void MD5_Update (mdContext, inBuf, inLen)
MD5_CTX *mdContext;
unsigned char *inBuf;
unsigned int inLen;
{
UINT4 in[16];
int mdi;
unsigned int i, ii;
/* compute number of bytes mod 64 */
mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
/* update number of bits */
if ((mdContext->i[0] + ((UINT4)inLen << 3)) < mdContext->i[0])
mdContext->i[1]++;
mdContext->i[0] += ((UINT4)inLen << 3);
mdContext->i[1] += ((UINT4)inLen >> 29);
while (inLen--) {
/* add new character to buffer, increment mdi */
mdContext->in[mdi++] = *inBuf++;
/* transform if necessary */
if (mdi == 0x40) {
for (i = 0, ii = 0; i < 16; i++, ii += 4)
in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
(((UINT4)mdContext->in[ii+2]) << 16) |
(((UINT4)mdContext->in[ii+1]) << 8) |
((UINT4)mdContext->in[ii]);
Transform (mdContext->buf, in);
mdi = 0;
}
}
}
/* The routine MD5Final terminates the message-digest computation and
ends with the desired message digest in mdContext->digest[0...15].
*/
void MD5_Final (hash, mdContext)
unsigned char hash[];
MD5_CTX *mdContext;
{
UINT4 in[16];
int mdi;
unsigned int i, ii;
unsigned int padLen;
/* save number of bits */
in[14] = mdContext->i[0];
in[15] = mdContext->i[1];
/* compute number of bytes mod 64 */
mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
/* pad out to 56 mod 64 */
padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi);
MD5_Update (mdContext, PADDING, padLen);
/* append length in bits and transform */
for (i = 0, ii = 0; i < 14; i++, ii += 4)
in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
(((UINT4)mdContext->in[ii+2]) << 16) |
(((UINT4)mdContext->in[ii+1]) << 8) |
((UINT4)mdContext->in[ii]);
Transform (mdContext->buf, in);
/* store buffer in digest */
for (i = 0, ii = 0; i < 4; i++, ii += 4) {
mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF);
mdContext->digest[ii+1] =
(unsigned char)((mdContext->buf[i] >> 8) & 0xFF);
mdContext->digest[ii+2] =
(unsigned char)((mdContext->buf[i] >> 16) & 0xFF);
mdContext->digest[ii+3] =
(unsigned char)((mdContext->buf[i] >> 24) & 0xFF);
}
memcpy(hash, mdContext->digest, 16);
}
/* Basic MD5 step. Transforms buf based on in.
*/
static void Transform (buf, in)
UINT4 *buf;
UINT4 *in;
{
UINT4 a = buf[0], b = buf[1], c = buf[2], d = buf[3];
/* Round 1 */
#define S11 7
#define S12 12
#define S13 17
#define S14 22
FF ( a, b, c, d, in[ 0], S11, UL(3614090360)); /* 1 */
FF ( d, a, b, c, in[ 1], S12, UL(3905402710)); /* 2 */
FF ( c, d, a, b, in[ 2], S13, UL( 606105819)); /* 3 */
FF ( b, c, d, a, in[ 3], S14, UL(3250441966)); /* 4 */
FF ( a, b, c, d, in[ 4], S11, UL(4118548399)); /* 5 */
FF ( d, a, b, c, in[ 5], S12, UL(1200080426)); /* 6 */
FF ( c, d, a, b, in[ 6], S13, UL(2821735955)); /* 7 */
FF ( b, c, d, a, in[ 7], S14, UL(4249261313)); /* 8 */
FF ( a, b, c, d, in[ 8], S11, UL(1770035416)); /* 9 */
FF ( d, a, b, c, in[ 9], S12, UL(2336552879)); /* 10 */
FF ( c, d, a, b, in[10], S13, UL(4294925233)); /* 11 */
FF ( b, c, d, a, in[11], S14, UL(2304563134)); /* 12 */
FF ( a, b, c, d, in[12], S11, UL(1804603682)); /* 13 */
FF ( d, a, b, c, in[13], S12, UL(4254626195)); /* 14 */
FF ( c, d, a, b, in[14], S13, UL(2792965006)); /* 15 */
FF ( b, c, d, a, in[15], S14, UL(1236535329)); /* 16 */
/* Round 2 */
#define S21 5
#define S22 9
#define S23 14
#define S24 20
GG ( a, b, c, d, in[ 1], S21, UL(4129170786)); /* 17 */
GG ( d, a, b, c, in[ 6], S22, UL(3225465664)); /* 18 */
GG ( c, d, a, b, in[11], S23, UL( 643717713)); /* 19 */
GG ( b, c, d, a, in[ 0], S24, UL(3921069994)); /* 20 */
GG ( a, b, c, d, in[ 5], S21, UL(3593408605)); /* 21 */
GG ( d, a, b, c, in[10], S22, UL( 38016083)); /* 22 */
GG ( c, d, a, b, in[15], S23, UL(3634488961)); /* 23 */
GG ( b, c, d, a, in[ 4], S24, UL(3889429448)); /* 24 */
GG ( a, b, c, d, in[ 9], S21, UL( 568446438)); /* 25 */
GG ( d, a, b, c, in[14], S22, UL(3275163606)); /* 26 */
GG ( c, d, a, b, in[ 3], S23, UL(4107603335)); /* 27 */
GG ( b, c, d, a, in[ 8], S24, UL(1163531501)); /* 28 */
GG ( a, b, c, d, in[13], S21, UL(2850285829)); /* 29 */
GG ( d, a, b, c, in[ 2], S22, UL(4243563512)); /* 30 */
GG ( c, d, a, b, in[ 7], S23, UL(1735328473)); /* 31 */
GG ( b, c, d, a, in[12], S24, UL(2368359562)); /* 32 */
/* Round 3 */
#define S31 4
#define S32 11
#define S33 16
#define S34 23
HH ( a, b, c, d, in[ 5], S31, UL(4294588738)); /* 33 */
HH ( d, a, b, c, in[ 8], S32, UL(2272392833)); /* 34 */
HH ( c, d, a, b, in[11], S33, UL(1839030562)); /* 35 */
HH ( b, c, d, a, in[14], S34, UL(4259657740)); /* 36 */
HH ( a, b, c, d, in[ 1], S31, UL(2763975236)); /* 37 */
HH ( d, a, b, c, in[ 4], S32, UL(1272893353)); /* 38 */
HH ( c, d, a, b, in[ 7], S33, UL(4139469664)); /* 39 */
HH ( b, c, d, a, in[10], S34, UL(3200236656)); /* 40 */
HH ( a, b, c, d, in[13], S31, UL( 681279174)); /* 41 */
HH ( d, a, b, c, in[ 0], S32, UL(3936430074)); /* 42 */
HH ( c, d, a, b, in[ 3], S33, UL(3572445317)); /* 43 */
HH ( b, c, d, a, in[ 6], S34, UL( 76029189)); /* 44 */
HH ( a, b, c, d, in[ 9], S31, UL(3654602809)); /* 45 */
HH ( d, a, b, c, in[12], S32, UL(3873151461)); /* 46 */
HH ( c, d, a, b, in[15], S33, UL( 530742520)); /* 47 */
HH ( b, c, d, a, in[ 2], S34, UL(3299628645)); /* 48 */
/* Round 4 */
#define S41 6
#define S42 10
#define S43 15
#define S44 21
II ( a, b, c, d, in[ 0], S41, UL(4096336452)); /* 49 */
II ( d, a, b, c, in[ 7], S42, UL(1126891415)); /* 50 */
II ( c, d, a, b, in[14], S43, UL(2878612391)); /* 51 */
II ( b, c, d, a, in[ 5], S44, UL(4237533241)); /* 52 */
II ( a, b, c, d, in[12], S41, UL(1700485571)); /* 53 */
II ( d, a, b, c, in[ 3], S42, UL(2399980690)); /* 54 */
II ( c, d, a, b, in[10], S43, UL(4293915773)); /* 55 */
II ( b, c, d, a, in[ 1], S44, UL(2240044497)); /* 56 */
II ( a, b, c, d, in[ 8], S41, UL(1873313359)); /* 57 */
II ( d, a, b, c, in[15], S42, UL(4264355552)); /* 58 */
II ( c, d, a, b, in[ 6], S43, UL(2734768916)); /* 59 */
II ( b, c, d, a, in[13], S44, UL(1309151649)); /* 60 */
II ( a, b, c, d, in[ 4], S41, UL(4149444226)); /* 61 */
II ( d, a, b, c, in[11], S42, UL(3174756917)); /* 62 */
II ( c, d, a, b, in[ 2], S43, UL( 718787259)); /* 63 */
II ( b, c, d, a, in[ 9], S44, UL(3951481745)); /* 64 */
buf[0] += a;
buf[1] += b;
buf[2] += c;
buf[3] += d;
}
/*
***********************************************************************
** End of md5.c **
******************************** (cut) ********************************
*/

View File

@@ -0,0 +1,65 @@
/*
***********************************************************************
** md5.h -- header file for implementation of MD5 **
** RSA Data Security, Inc. MD5 Message-Digest Algorithm **
** Created: 2/17/90 RLR **
** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version **
** Revised (for MD5): RLR 4/27/91 **
** -- G modified to have y&~z instead of y&z **
** -- FF, GG, HH modified to add in last register done **
** -- Access pattern: round 2 works mod 5, round 3 works mod 3 **
** -- distinct additive constant for each step **
** -- round 4 added, working mod 7 **
***********************************************************************
*/
/*
***********************************************************************
** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
** **
** License to copy and use this software is granted provided that **
** it is identified as the "RSA Data Security, Inc. MD5 Message- **
** Digest Algorithm" in all material mentioning or referencing this **
** software or this function. **
** **
** License is also granted to make and use derivative works **
** provided that such works are identified as "derived from the RSA **
** Data Security, Inc. MD5 Message-Digest Algorithm" in all **
** material mentioning or referencing the derived work. **
** **
** RSA Data Security, Inc. makes no representations concerning **
** either the merchantability of this software or the suitability **
** of this software for any particular purpose. It is provided "as **
** is" without express or implied warranty of any kind. **
** **
** These notices must be retained in any copies of any part of this **
** documentation and/or software. **
***********************************************************************
*/
#ifndef __MD5_INCLUDE__
/* typedef a 32-bit type */
#ifdef _LP64
typedef unsigned int UINT4;
typedef int INT4;
#else
typedef unsigned long UINT4;
typedef long INT4;
#endif
#define _UINT4_T
/* Data structure for MD5 (Message-Digest) computation */
typedef struct {
UINT4 i[2]; /* number of _bits_ handled mod 2^64 */
UINT4 buf[4]; /* scratch buffer */
unsigned char in[64]; /* input buffer */
unsigned char digest[16]; /* actual digest after MD5Final call */
} MD5_CTX;
void MD5_Init ();
void MD5_Update ();
void MD5_Final ();
#define __MD5_INCLUDE__
#endif /* __MD5_INCLUDE__ */

View File

@@ -0,0 +1,761 @@
/*
* mtd - simple memory technology device manipulation tool
*
* Copyright (C) 2005 Waldemar Brodkorb <wbx@dass-it.de>,
* Copyright (C) 2005-2009 Felix Fietkau <nbd@openwrt.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
* The code is based on the linux-mtd examples.
*/
#include <limits.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/syscall.h>
#include <fcntl.h>
#include <errno.h>
#include <time.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/reboot.h>
#include <linux/reboot.h>
#include <mtd/mtd-user.h>
#include "fis.h"
#include "mtd.h"
#ifndef MTDREFRESH
#define MTDREFRESH _IO('M', 50)
#endif
#define MAX_ARGS 8
#define JFFS2_DEFAULT_DIR "" /* directory name without /, empty means root dir */
static char *buf = NULL;
static char *imagefile = NULL;
static char *jffs2file = NULL, *jffs2dir = JFFS2_DEFAULT_DIR;
static int buflen = 0;
int quiet;
int no_erase;
int mtdsize = 0;
int erasesize = 0;
int mtd_open(const char *mtd, bool block)
{
FILE *fp;
char dev[PATH_MAX];
int i;
int ret;
int flags = O_RDWR | O_SYNC;
if ((fp = fopen("/proc/mtd", "r"))) {
while (fgets(dev, sizeof(dev), fp)) {
if (sscanf(dev, "mtd%d:", &i) && strstr(dev, mtd)) {
snprintf(dev, sizeof(dev), "/dev/mtd%s/%d", (block ? "block" : ""), i);
if ((ret=open(dev, flags))<0) {
snprintf(dev, sizeof(dev), "/dev/mtd%s%d", (block ? "block" : ""), i);
ret=open(dev, flags);
}
fclose(fp);
return ret;
}
}
fclose(fp);
}
return open(mtd, flags);
}
int mtd_check_open(const char *mtd)
{
struct mtd_info_user mtdInfo;
int fd;
fd = mtd_open(mtd, false);
if(fd < 0) {
fprintf(stderr, "Could not open mtd device: %s\n", mtd);
return -1;
}
if(ioctl(fd, MEMGETINFO, &mtdInfo)) {
fprintf(stderr, "Could not get MTD device info from %s\n", mtd);
close(fd);
return -1;
}
mtdsize = mtdInfo.size;
erasesize = mtdInfo.erasesize;
return fd;
}
int mtd_erase_block(int fd, int offset)
{
struct erase_info_user mtdEraseInfo;
mtdEraseInfo.start = offset;
mtdEraseInfo.length = erasesize;
ioctl(fd, MEMUNLOCK, &mtdEraseInfo);
if (ioctl (fd, MEMERASE, &mtdEraseInfo) < 0)
return -1;
return 0;
}
int mtd_write_buffer(int fd, const char *buf, int offset, int length)
{
lseek(fd, offset, SEEK_SET);
write(fd, buf, length);
return 0;
}
static int
image_check(int imagefd, const char *mtd)
{
int ret = 1;
if (trx_check) {
ret = trx_check(imagefd, mtd, buf, &buflen);
}
return ret;
}
static int mtd_check(const char *mtd)
{
char *next = NULL;
char *str = NULL;
int fd;
if (strchr(mtd, ':')) {
str = strdup(mtd);
mtd = str;
}
do {
next = strchr(mtd, ':');
if (next) {
*next = 0;
next++;
}
fd = mtd_check_open(mtd);
if (fd < 0)
return 0;
if (!buf)
buf = malloc(erasesize);
close(fd);
mtd = next;
} while (next);
if (str)
free(str);
return 1;
}
static int
mtd_unlock(const char *mtd)
{
struct erase_info_user mtdLockInfo;
char *next = NULL;
char *str = NULL;
int fd;
if (strchr(mtd, ':')) {
str = strdup(mtd);
mtd = str;
}
do {
next = strchr(mtd, ':');
if (next) {
*next = 0;
next++;
}
fd = mtd_check_open(mtd);
if(fd < 0) {
fprintf(stderr, "Could not open mtd device: %s\n", mtd);
exit(1);
}
if (quiet < 2)
fprintf(stderr, "Unlocking %s ...\n", mtd);
mtdLockInfo.start = 0;
mtdLockInfo.length = mtdsize;
ioctl(fd, MEMUNLOCK, &mtdLockInfo);
close(fd);
mtd = next;
} while (next);
if (str)
free(str);
return 0;
}
static int
mtd_erase(const char *mtd)
{
int fd;
struct erase_info_user mtdEraseInfo;
if (quiet < 2)
fprintf(stderr, "Erasing %s ...\n", mtd);
fd = mtd_check_open(mtd);
if(fd < 0) {
fprintf(stderr, "Could not open mtd device: %s\n", mtd);
exit(1);
}
mtdEraseInfo.length = erasesize;
for (mtdEraseInfo.start = 0;
mtdEraseInfo.start < mtdsize;
mtdEraseInfo.start += erasesize) {
ioctl(fd, MEMUNLOCK, &mtdEraseInfo);
if(ioctl(fd, MEMERASE, &mtdEraseInfo))
fprintf(stderr, "Failed to erase block on %s at 0x%x\n", mtd, mtdEraseInfo.start);
}
close(fd);
return 0;
}
static int
mtd_refresh(const char *mtd)
{
int fd;
if (quiet < 2)
fprintf(stderr, "Refreshing mtd partition %s ... ", mtd);
fd = mtd_check_open(mtd);
if(fd < 0) {
fprintf(stderr, "Could not open mtd device: %s\n", mtd);
exit(1);
}
if (ioctl(fd, MTDREFRESH, NULL)) {
fprintf(stderr, "Failed to refresh the MTD device\n");
close(fd);
exit(1);
}
close(fd);
if (quiet < 2)
fprintf(stderr, "\n");
return 0;
}
static void
indicate_writing(const char *mtd)
{
if (quiet < 2)
fprintf(stderr, "\nWriting from %s to %s ... ", imagefile, mtd);
if (!quiet)
fprintf(stderr, " [ ]");
}
static int
mtd_write(int imagefd, const char *mtd, char *fis_layout, size_t part_offset)
{
char *next = NULL;
char *str = NULL;
int fd, result;
ssize_t r, w, e;
ssize_t skip = 0;
uint32_t offset = 0;
int jffs2_replaced = 0;
#ifdef FIS_SUPPORT
static struct fis_part new_parts[MAX_ARGS];
static struct fis_part old_parts[MAX_ARGS];
int n_new = 0, n_old = 0;
if (fis_layout) {
const char *tmp = mtd;
char *word, *brkt;
int ret;
memset(&old_parts, 0, sizeof(old_parts));
memset(&new_parts, 0, sizeof(new_parts));
do {
next = strchr(tmp, ':');
if (!next)
next = (char *) tmp + strlen(tmp);
memcpy(old_parts[n_old].name, tmp, next - tmp);
n_old++;
tmp = next + 1;
} while(*next);
for (word = strtok_r(fis_layout, ",", &brkt);
word;
word = strtok_r(NULL, ",", &brkt)) {
tmp = strtok(word, ":");
strncpy((char *) new_parts[n_new].name, tmp, sizeof(new_parts[n_new].name) - 1);
tmp = strtok(NULL, ":");
if (!tmp)
goto next;
new_parts[n_new].size = strtoul(tmp, NULL, 0);
tmp = strtok(NULL, ":");
if (!tmp)
goto next;
new_parts[n_new].loadaddr = strtoul(tmp, NULL, 16);
next:
n_new++;
}
ret = fis_validate(old_parts, n_old, new_parts, n_new);
if (ret < 0) {
fprintf(stderr, "Failed to validate the new FIS partition table\n");
exit(1);
}
if (ret == 0)
fis_layout = NULL;
}
#endif
if (strchr(mtd, ':')) {
str = strdup(mtd);
mtd = str;
}
r = 0;
resume:
next = strchr(mtd, ':');
if (next) {
*next = 0;
next++;
}
fd = mtd_check_open(mtd);
if(fd < 0) {
fprintf(stderr, "Could not open mtd device: %s\n", mtd);
exit(1);
}
if (part_offset > 0) {
fprintf(stderr, "Seeking on mtd device '%s' to: %u\n", mtd, part_offset);
lseek(fd, part_offset, SEEK_SET);
}
indicate_writing(mtd);
w = e = 0;
for (;;) {
/* buffer may contain data already (from trx check or last mtd partition write attempt) */
while (buflen < erasesize) {
r = read(imagefd, buf + buflen, erasesize - buflen);
if (r < 0) {
if ((errno == EINTR) || (errno == EAGAIN))
continue;
else {
perror("read");
break;
}
}
if (r == 0)
break;
buflen += r;
}
if (buflen == 0)
break;
if (skip > 0) {
skip -= buflen;
buflen = 0;
if (skip <= 0)
indicate_writing(mtd);
continue;
}
if (jffs2file) {
if (memcmp(buf, JFFS2_EOF, sizeof(JFFS2_EOF) - 1) == 0) {
if (!quiet)
fprintf(stderr, "\b\b\b ");
if (quiet < 2)
fprintf(stderr, "\nAppending jffs2 data from %s to %s...", jffs2file, mtd);
/* got an EOF marker - this is the place to add some jffs2 data */
skip = mtd_replace_jffs2(mtd, fd, e, jffs2file);
jffs2_replaced = 1;
/* don't add it again */
jffs2file = NULL;
w += skip;
e += skip;
skip -= buflen;
buflen = 0;
offset = 0;
continue;
}
/* no EOF marker, make sure we figure out the last inode number
* before appending some data */
mtd_parse_jffs2data(buf, jffs2dir);
}
/* need to erase the next block before writing data to it */
if(!no_erase)
{
while (w + buflen > e) {
if (!quiet)
fprintf(stderr, "\b\b\b[e]");
if (mtd_erase_block(fd, e) < 0) {
if (next) {
if (w < e) {
write(fd, buf + offset, e - w);
offset = e - w;
}
w = 0;
e = 0;
close(fd);
mtd = next;
fprintf(stderr, "\b\b\b \n");
goto resume;
} else {
fprintf(stderr, "Failed to erase block\n");
exit(1);
}
}
/* erase the chunk */
e += erasesize;
}
}
if (!quiet)
fprintf(stderr, "\b\b\b[w]");
if ((result = write(fd, buf + offset, buflen)) < buflen) {
if (result < 0) {
fprintf(stderr, "Error writing image.\n");
exit(1);
} else {
fprintf(stderr, "Insufficient space.\n");
exit(1);
}
}
w += buflen;
buflen = 0;
offset = 0;
}
if (jffs2_replaced && trx_fixup) {
trx_fixup(fd, mtd);
}
if (!quiet)
fprintf(stderr, "\b\b\b\b ");
done:
if (quiet < 2)
fprintf(stderr, "\n");
#ifdef FIS_SUPPORT
if (fis_layout) {
if (fis_remap(old_parts, n_old, new_parts, n_new) < 0)
fprintf(stderr, "Failed to update the FIS partition table\n");
}
#endif
close(fd);
return 0;
}
static void usage(void)
{
fprintf(stderr, "Usage: mtd [<options> ...] <command> [<arguments> ...] <device>[:<device>...]\n\n"
"The device is in the format of mtdX (eg: mtd4) or its label.\n"
"mtd recognizes these commands:\n"
" unlock unlock the device\n"
" refresh refresh mtd partition\n"
" erase erase all data on device\n"
" write <imagefile>|- write <imagefile> (use - for stdin) to device\n"
" jffs2write <file> append <file> to the jffs2 partition on the device\n");
if (mtd_fixtrx) {
fprintf(stderr,
" fixtrx fix the checksum in a trx header on first boot\n");
}
if (mtd_fixseama) {
fprintf(stderr,
" fixseama fix the checksum in a seama header on first boot\n");
}
fprintf(stderr,
"Following options are available:\n"
" -q quiet mode (once: no [w] on writing,\n"
" twice: no status messages)\n"
" -n write without first erasing the blocks\n"
" -r reboot after successful command\n"
" -f force write without trx checks\n"
" -e <device> erase <device> before executing the command\n"
" -d <name> directory for jffs2write, defaults to \"tmp\"\n"
" -j <name> integrate <file> into jffs2 data when writing an image\n"
" -p write beginning at partition offset\n");
if (mtd_fixtrx) {
fprintf(stderr,
" -o offset offset of the image header in the partition(for fixtrx)\n");
}
fprintf(stderr,
#ifdef FIS_SUPPORT
" -F <part>[:<size>[:<entrypoint>]][,<part>...]\n"
" alter the fis partition table to create new partitions replacing\n"
" the partitions provided as argument to the write command\n"
" (only valid together with the write command)\n"
#endif
"\n"
"Example: To write linux.trx to mtd4 labeled as linux and reboot afterwards\n"
" mtd -r write linux.trx linux\n\n");
exit(1);
}
static void do_reboot(void)
{
fprintf(stderr, "Rebooting ...\n");
fflush(stderr);
/* try regular reboot method first */
system("/sbin/reboot");
sleep(2);
/* if we're still alive at this point, force the kernel to reboot */
syscall(SYS_reboot,LINUX_REBOOT_MAGIC1,LINUX_REBOOT_MAGIC2,LINUX_REBOOT_CMD_RESTART,NULL);
}
int main (int argc, char **argv)
{
int ch, i, boot, imagefd = 0, force, unlocked;
char *erase[MAX_ARGS], *device = NULL;
char *fis_layout = NULL;
size_t offset = 0, part_offset = 0;
enum {
CMD_ERASE,
CMD_WRITE,
CMD_UNLOCK,
CMD_REFRESH,
CMD_JFFS2WRITE,
CMD_FIXTRX,
CMD_FIXSEAMA,
} cmd = -1;
erase[0] = NULL;
boot = 0;
force = 0;
buflen = 0;
quiet = 0;
no_erase = 0;
while ((ch = getopt(argc, argv,
#ifdef FIS_SUPPORT
"F:"
#endif
"frnqe:d:j:p:o:")) != -1)
switch (ch) {
case 'f':
force = 1;
break;
case 'r':
boot = 1;
break;
case 'n':
no_erase = 1;
break;
case 'j':
jffs2file = optarg;
break;
case 'q':
quiet++;
break;
case 'e':
i = 0;
while ((erase[i] != NULL) && ((i + 1) < MAX_ARGS))
i++;
erase[i++] = optarg;
erase[i] = NULL;
break;
case 'd':
jffs2dir = optarg;
break;
case 'p':
errno = 0;
part_offset = strtoul(optarg, 0, 0);
if (errno) {
fprintf(stderr, "-p: illegal numeric string\n");
usage();
}
break;
case 'o':
if (!mtd_fixtrx) {
fprintf(stderr, "-o: is not available on this platform\n");
usage();
}
errno = 0;
offset = strtoul(optarg, 0, 0);
if (errno) {
fprintf(stderr, "-o: illegal numeric string\n");
usage();
}
break;
#ifdef FIS_SUPPORT
case 'F':
fis_layout = optarg;
break;
#endif
case '?':
default:
usage();
}
argc -= optind;
argv += optind;
if (argc < 2)
usage();
if ((strcmp(argv[0], "unlock") == 0) && (argc == 2)) {
cmd = CMD_UNLOCK;
device = argv[1];
} else if ((strcmp(argv[0], "refresh") == 0) && (argc == 2)) {
cmd = CMD_REFRESH;
device = argv[1];
} else if ((strcmp(argv[0], "erase") == 0) && (argc == 2)) {
cmd = CMD_ERASE;
device = argv[1];
} else if (((strcmp(argv[0], "fixtrx") == 0) && (argc == 2)) && mtd_fixtrx) {
cmd = CMD_FIXTRX;
device = argv[1];
} else if (((strcmp(argv[0], "fixseama") == 0) && (argc == 2)) && mtd_fixseama) {
cmd = CMD_FIXSEAMA;
device = argv[1];
} else if ((strcmp(argv[0], "write") == 0) && (argc == 3)) {
cmd = CMD_WRITE;
device = argv[2];
if (strcmp(argv[1], "-") == 0) {
imagefile = "<stdin>";
imagefd = 0;
} else {
imagefile = argv[1];
if ((imagefd = open(argv[1], O_RDONLY)) < 0) {
fprintf(stderr, "Couldn't open image file: %s!\n", imagefile);
exit(1);
}
}
if (!mtd_check(device)) {
fprintf(stderr, "Can't open device for writing!\n");
exit(1);
}
/* check trx file before erasing or writing anything */
if (!image_check(imagefd, device) && !force) {
fprintf(stderr, "Image check failed.\n");
exit(1);
}
} else if ((strcmp(argv[0], "jffs2write") == 0) && (argc == 3)) {
cmd = CMD_JFFS2WRITE;
device = argv[2];
imagefile = argv[1];
if (!mtd_check(device)) {
fprintf(stderr, "Can't open device for writing!\n");
exit(1);
}
} else {
usage();
}
sync();
i = 0;
unlocked = 0;
while (erase[i] != NULL) {
mtd_unlock(erase[i]);
mtd_erase(erase[i]);
if (strcmp(erase[i], device) == 0)
unlocked = 1;
i++;
}
switch (cmd) {
case CMD_UNLOCK:
if (!unlocked)
mtd_unlock(device);
break;
case CMD_ERASE:
if (!unlocked)
mtd_unlock(device);
mtd_erase(device);
break;
case CMD_WRITE:
if (!unlocked)
mtd_unlock(device);
mtd_write(imagefd, device, fis_layout, part_offset);
break;
case CMD_JFFS2WRITE:
if (!unlocked)
mtd_unlock(device);
mtd_write_jffs2(device, imagefile, jffs2dir);
break;
case CMD_REFRESH:
mtd_refresh(device);
break;
case CMD_FIXTRX:
if (mtd_fixtrx) {
mtd_fixtrx(device, offset);
}
case CMD_FIXSEAMA:
if (mtd_fixseama)
mtd_fixseama(device, 0);
break;
}
sync();
if (boot)
do_reboot();
return 0;
}

View File

@@ -0,0 +1,29 @@
#ifndef __mtd_h
#define __mtd_h
#include <stdbool.h>
#ifdef target_brcm47xx
#define target_brcm 1
#endif
#define JFFS2_EOF "\xde\xad\xc0\xde"
extern int quiet;
extern int mtdsize;
extern int erasesize;
extern int mtd_open(const char *mtd, bool block);
extern int mtd_check_open(const char *mtd);
extern int mtd_erase_block(int fd, int offset);
extern int mtd_write_buffer(int fd, const char *buf, int offset, int length);
extern int mtd_write_jffs2(const char *mtd, const char *filename, const char *dir);
extern int mtd_replace_jffs2(const char *mtd, int fd, int ofs, const char *filename);
extern void mtd_parse_jffs2data(const char *buf, const char *dir);
/* target specific functions */
extern int trx_fixup(int fd, const char *name) __attribute__ ((weak));
extern int trx_check(int imagefd, const char *mtd, char *buf, int *len) __attribute__ ((weak));
extern int mtd_fixtrx(const char *mtd, size_t offset) __attribute__ ((weak));
extern int mtd_fixseama(const char *mtd, size_t offset) __attribute__ ((weak));
#endif /* __mtd_h */

View File

@@ -0,0 +1,179 @@
/*
* seama.c
*
* Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org>
*
* Based on the trx fixup code:
* Copyright (C) 2005 Mike Baker
* Copyright (C) 2008 Felix Fietkau <nbd@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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include <arpa/inet.h>
#include <sys/ioctl.h>
#include <mtd/mtd-user.h>
#include "mtd.h"
#include "seama.h"
#include "md5.h"
#if __BYTE_ORDER == __BIG_ENDIAN
#define STORE32_LE(X) ((((X) & 0x000000FF) << 24) | (((X) & 0x0000FF00) << 8) | (((X) & 0x00FF0000) >> 8) | (((X) & 0xFF000000) >> 24))
#elif __BYTE_ORDER == __LITTLE_ENDIAN
#define STORE32_LE(X) (X)
#else
#error unknown endianness!
#endif
ssize_t pread(int fd, void *buf, size_t count, off_t offset);
ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
int
seama_fix_md5(char *buf, size_t len)
{
struct seama_hdr *shdr;
char *data;
size_t msize;
size_t isize;
MD5_CTX ctx;
unsigned char digest[16];
int i;
if (len < sizeof(struct seama_hdr))
return -1;
shdr = (struct seama_hdr *) buf;
if (shdr->magic != htonl(SEAMA_MAGIC)) {
fprintf(stderr, "no SEAMA header found\n");
return -1;
}
isize = ntohl(shdr->size);
msize = ntohs(shdr->metasize);
if (isize == 0) {
/* the image contains no checksum */
return -1;
}
len -= sizeof(struct seama_hdr) + sizeof(digest) + msize;
if (isize > len)
isize = len;
data = buf + sizeof(struct seama_hdr) + sizeof(digest) + msize;
MD5_Init(&ctx);
MD5_Update(&ctx, data, isize);
MD5_Final(digest, &ctx);
if (!memcmp(digest, &buf[sizeof(struct seama_hdr)], sizeof(digest))) {
if (quiet < 2)
fprintf(stderr, "the header is fixed already\n");
return -1;
}
if (quiet < 2) {
fprintf(stderr, "new size:%u, new MD5: ", isize);
for (i = 0; i < sizeof(digest); i++)
fprintf(stderr, "%02x", digest[i]);
fprintf(stderr, "\n");
}
/* update the size in the image */
shdr->size = htonl(isize);
/* update the checksum in the image */
for (i = 0; i < sizeof(digest); i++)
buf[sizeof(struct seama_hdr) + i] = digest[i];
return 0;
}
int
mtd_fixseama(const char *mtd, size_t offset)
{
int fd;
char *buf;
ssize_t res;
size_t block_offset;
if (quiet < 2)
fprintf(stderr, "Trying to fix SEAMA header in %s at 0x%x...\n",
mtd, offset);
block_offset = offset & ~(erasesize - 1);
offset -= block_offset;
fd = mtd_check_open(mtd);
if(fd < 0) {
fprintf(stderr, "Could not open mtd device: %s\n", mtd);
exit(1);
}
if (block_offset + erasesize > mtdsize) {
fprintf(stderr, "Offset too large, device size 0x%x\n",
mtdsize);
exit(1);
}
buf = malloc(mtdsize);
if (!buf) {
perror("malloc");
exit(1);
}
res = pread(fd, buf, mtdsize, block_offset);
if (res != mtdsize) {
perror("pread");
exit(1);
}
if (seama_fix_md5(buf, mtdsize))
goto out;
if (mtd_erase_block(fd, block_offset)) {
fprintf(stderr, "Can't erease block at 0x%x (%s)\n",
block_offset, strerror(errno));
exit(1);
}
if (quiet < 2)
fprintf(stderr, "Rewriting block at 0x%x\n", block_offset);
if (pwrite(fd, buf, erasesize, block_offset) != erasesize) {
fprintf(stderr, "Error writing block (%s)\n", strerror(errno));
exit(1);
}
if (quiet < 2)
fprintf(stderr, "Done.\n");
out:
close (fd);
sync();
return 0;
}

View File

@@ -0,0 +1,108 @@
/* vi: set sw=4 ts=4: */
/*
* (SEA)ttle i(MA)ge is the image which used in project seattle.
*
* Created by David Hsieh <david_hsieh@alphanetworks.com>
* Copyright (C) 2008-2009 Alpha Networks, Inc.
*
* This file is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either'
* version 2.1 of the License, or (at your option) any later version.
*
* The GNU C Library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the GNU C Library; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA.
*/
#ifndef __SEAMA_HEADER_FILE__
#define __SEAMA_HEADER_FILE__
#include <stdint.h>
#define SEAMA_MAGIC 0x5EA3A417
/*
* SEAMA looks like the following map.
* All the data of the header should be in network byte order.
*
* +-------------+-------------+------------
* | SEAMA magic | ^
* +-------------+-------------+ |
* | reserved | meta size | |
* +-------------+-------------+ header
* | image size (0 bytes) | |
* +-------------+-------------+ |
* ~ Meta data ~ v
* +-------------+-------------+------------
* | SEAMA magic | ^ ^
* +-------------+-------------+ | |
* | reserved | meta size | | |
* +-------------+-------------+ | |
* | image size | | |
* +-------------+-------------+ header |
* | | | |
* | 16 bytes of MD5 digest | | |
* | | | |
* | | | |
* +-------------+-------------+ | |
* ~ Meta data ~ v |
* +-------------+-------------+------- |
* | | |
* | Image of the 1st entity | |
* ~ ~ 1st entity
* | | |
* | | v
* +-------------+-------------+-------------
* | SEAMA magic | ^ ^
* +-------------+-------------+ | |
* | reserved | meta size | | |
* +-------------+-------------+ | |
* | image size | | |
* +-------------+-------------+ header |
* | | | |
* | 16 bytes of MD5 digest | | |
* | | | |
* | | | |
* +-------------+-------------+ | |
* ~ Meta data ~ v |
* +-------------+-------------+------- |
* | | |
* | Image of the 2nd entity | |
* ~ ~ 2nd entity
* | | |
* | | v
* +-------------+-------------+-------------
*/
/*
* SEAMA header
*
* |<-------- 32 bits -------->|
* +-------------+-------------+
* | SEAMA magic |
* +-------------+-------------+
* | reserved | meta size |
* +-------------+-------------+
* | image size |
* +-------------+-------------+
*/
/* seama header */
typedef struct seama_hdr seamahdr_t;
struct seama_hdr
{
uint32_t magic; /* should always be SEAMA_MAGIC. */
uint16_t reserved; /* reserved for */
uint16_t metasize; /* size of the META data */
uint32_t size; /* size of the image */
} __attribute__ ((packed));
#endif

View File

@@ -0,0 +1,220 @@
/*
* trx.c
*
* Copyright (C) 2005 Mike Baker
* Copyright (C) 2008 Felix Fietkau <nbd@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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <mtd/mtd-user.h>
#include "mtd.h"
#include "crc32.h"
#define TRX_MAGIC 0x30524448 /* "HDR0" */
struct trx_header {
uint32_t magic; /* "HDR0" */
uint32_t len; /* Length of file including header */
uint32_t crc32; /* 32-bit CRC from flag_version to end of file */
uint32_t flag_version; /* 0:15 flags, 16:31 version */
uint32_t offsets[3]; /* Offsets of partitions from start of header */
};
#if __BYTE_ORDER == __BIG_ENDIAN
#define STORE32_LE(X) ((((X) & 0x000000FF) << 24) | (((X) & 0x0000FF00) << 8) | (((X) & 0x00FF0000) >> 8) | (((X) & 0xFF000000) >> 24))
#elif __BYTE_ORDER == __LITTLE_ENDIAN
#define STORE32_LE(X) (X)
#else
#error unknown endianness!
#endif
ssize_t pread(int fd, void *buf, size_t count, off_t offset);
ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset);
int
trx_fixup(int fd, const char *name)
{
struct mtd_info_user mtdInfo;
unsigned long len;
struct trx_header *trx;
void *ptr, *scan;
int bfd;
if (ioctl(fd, MEMGETINFO, &mtdInfo) < 0) {
fprintf(stderr, "Failed to get mtd info\n");
goto err;
}
len = mtdInfo.size;
if (mtdInfo.size <= 0) {
fprintf(stderr, "Invalid MTD device size\n");
goto err;
}
bfd = mtd_open(name, true);
ptr = mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_SHARED, bfd, 0);
if (!ptr || (ptr == (void *) -1)) {
perror("mmap");
goto err1;
}
trx = ptr;
if (trx->magic != TRX_MAGIC) {
fprintf(stderr, "TRX header not found\n");
goto err;
}
scan = ptr + offsetof(struct trx_header, flag_version);
trx->crc32 = crc32buf(scan, trx->len - (scan - ptr));
msync(ptr, sizeof(struct trx_header), MS_SYNC|MS_INVALIDATE);
munmap(ptr, len);
close(bfd);
return 0;
err1:
close(bfd);
err:
fprintf(stderr, "Error fixing up TRX header\n");
return -1;
}
int
trx_check(int imagefd, const char *mtd, char *buf, int *len)
{
const struct trx_header *trx = (const struct trx_header *) buf;
int fd;
if (strcmp(mtd, "linux") != 0)
return 1;
*len = read(imagefd, buf, 32);
if (*len < 32) {
fprintf(stdout, "Could not get image header, file too small (%d bytes)\n", *len);
return 0;
}
if (trx->magic != TRX_MAGIC || trx->len < sizeof(struct trx_header)) {
if (quiet < 2) {
fprintf(stderr, "Bad trx header\n");
fprintf(stderr, "This is not the correct file format; refusing to flash.\n"
"Please specify the correct file or use -f to force.\n");
}
return 0;
}
/* check if image fits to mtd device */
fd = mtd_check_open(mtd);
if(fd < 0) {
fprintf(stderr, "Could not open mtd device: %s\n", mtd);
exit(1);
}
if(mtdsize < trx->len) {
fprintf(stderr, "Image too big for partition: %s\n", mtd);
close(fd);
return 0;
}
close(fd);
return 1;
}
int
mtd_fixtrx(const char *mtd, size_t offset)
{
int fd;
struct trx_header *trx;
char *buf;
ssize_t res;
size_t block_offset;
if (quiet < 2)
fprintf(stderr, "Trying to fix trx header in %s at 0x%x...\n", mtd, offset);
fd = mtd_check_open(mtd);
if(fd < 0) {
fprintf(stderr, "Could not open mtd device: %s\n", mtd);
exit(1);
}
block_offset = offset & ~(erasesize - 1);
offset -= block_offset;
if (block_offset + erasesize > mtdsize) {
fprintf(stderr, "Offset too large, device size 0x%x\n", mtdsize);
exit(1);
}
buf = malloc(erasesize);
if (!buf) {
perror("malloc");
exit(1);
}
res = pread(fd, buf, erasesize, block_offset);
if (res != erasesize) {
perror("pread");
exit(1);
}
trx = (struct trx_header *) (buf + offset);
if (trx->magic != STORE32_LE(0x30524448)) {
fprintf(stderr, "No trx magic found\n");
exit(1);
}
if (trx->len == STORE32_LE(erasesize - offset)) {
if (quiet < 2)
fprintf(stderr, "Header already fixed, exiting\n");
close(fd);
return 0;
}
trx->len = STORE32_LE(erasesize - offset);
trx->crc32 = STORE32_LE(crc32buf((char*) &trx->flag_version, erasesize - offset - 3*4));
if (mtd_erase_block(fd, block_offset)) {
fprintf(stderr, "Can't erease block at 0x%x (%s)\n", block_offset, strerror(errno));
exit(1);
}
if (quiet < 2)
fprintf(stderr, "New crc32: 0x%x, rewriting block\n", trx->crc32);
if (pwrite(fd, buf, erasesize, block_offset) != erasesize) {
fprintf(stderr, "Error writing block (%s)\n", strerror(errno));
exit(1);
}
if (quiet < 2)
fprintf(stderr, "Done.\n");
close (fd);
sync();
return 0;
}

View File

@@ -1,45 +0,0 @@
#
# Copyright (C) 2011 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=om-watchdog
PKG_RELEASE:=1
PKG_VERSION:=1
include $(INCLUDE_DIR)/package.mk
define Package/om-watchdog
SECTION:=base
CATEGORY:=Base system
TITLE:=om watchdog
URL:=http://openwrt.org/
endef
define Package/om-watchdog/description
This package contains the hw watchdog script for the OM1P and OM2P device.
endef
define Build/Prepare
endef
define Build/Compile
endef
define Build/Compile
endef
define Package/om-watchdog/install
$(INSTALL_DIR) $(1)/etc/init.d/
$(INSTALL_DIR) $(1)/sbin/
$(INSTALL_BIN) ./files/om-watchdog.init $(1)/etc/init.d/om-watchdog
$(INSTALL_BIN) ./files/om-watchdog $(1)/sbin/om-watchdog
endef
$(eval $(call BuildPackage,om-watchdog))

Some files were not shown because too many files have changed in this diff Show More