summaryrefslogtreecommitdiffstats
path: root/target/linux/ifxmips/files/drivers
diff options
context:
space:
mode:
authorthl <thl@3c298f89-4303-0410-b956-a3cf2f4a3e73>2008-12-16 14:07:55 +0000
committerthl <thl@3c298f89-4303-0410-b956-a3cf2f4a3e73>2008-12-16 14:07:55 +0000
commit6ad1668c37fef80075e1a69b0ef71d0f8bbeb9c3 (patch)
tree07dc39510a01c7dca62cd1d2a794c1800ecab6c2 /target/linux/ifxmips/files/drivers
parent84938fc03d0471ec555fecec3569f25cd1ace3ed (diff)
[ifxmips] cleanup sources and prepare for 2.6.27
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@13660 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/ifxmips/files/drivers')
-rw-r--r--target/linux/ifxmips/files/drivers/char/ifxmips_eeprom.c262
-rw-r--r--target/linux/ifxmips/files/drivers/char/ifxmips_ssc.c731
-rw-r--r--target/linux/ifxmips/files/drivers/leds/leds-ifxmips.c56
-rw-r--r--target/linux/ifxmips/files/drivers/mtd/maps/ifxmips.c5
-rw-r--r--target/linux/ifxmips/files/drivers/net/ifxmips_mii0.c143
-rw-r--r--target/linux/ifxmips/files/drivers/serial/ifxmips_asc.c322
6 files changed, 664 insertions, 855 deletions
diff --git a/target/linux/ifxmips/files/drivers/char/ifxmips_eeprom.c b/target/linux/ifxmips/files/drivers/char/ifxmips_eeprom.c
index ea1303cd6..e1d37934d 100644
--- a/target/linux/ifxmips/files/drivers/char/ifxmips_eeprom.c
+++ b/target/linux/ifxmips/files/drivers/char/ifxmips_eeprom.c
@@ -16,11 +16,11 @@
* This driver was originally based on the INCA-IP driver, but due to
* fundamental conceptual drawbacks there has been changed a lot.
*
- * Based on INCA-IP driver Copyright (c) 2003 Gary Jennejohn <gj@denx.de>
- * Based on the VxWorks drivers Copyright (c) 2002, Infineon Technologies.
+ * Based on INCA-IP driver Copyright(c) 2003 Gary Jennejohn <gj@denx.de>
+ * Based on the VxWorks drivers Copyright(c) 2002, Infineon Technologies.
*
- * Copyright (C) 2006 infineon
- * Copyright (C) 2007 John Crispin <blogic@openwrt.org>
+ * Copyright(C) 2006 infineon
+ * Copyright(C) 2007 John Crispin <blogic@openwrt.org>
*
*/
@@ -43,38 +43,38 @@
#include <linux/delay.h>
#include <linux/spinlock.h>
#include <linux/slab.h>
-#include <asm/system.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/uaccess.h>
-#include <asm/bitops.h>
+#include <linux/io.h>
+#include <linux/irq.h>
+#include <linux/uaccess.h>
+#include <linux/bitops.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/version.h>
+#include <asm/system.h>
#include <asm/ifxmips/ifxmips.h>
#include <asm/ifxmips/ifxmips_irq.h>
#include <asm/ifxmips/ifx_ssc_defines.h>
#include <asm/ifxmips/ifx_ssc.h>
/* allow the user to set the major device number */
-static int ifxmips_eeprom_maj = 0;
+static int ifxmips_eeprom_maj;
-extern int ifx_ssc_init (void);
-extern int ifx_ssc_open (struct inode *inode, struct file *filp);
-extern int ifx_ssc_close (struct inode *inode, struct file *filp);
-extern void ifx_ssc_cleanup_module (void);
-extern int ifx_ssc_ioctl (struct inode *inode, struct file *filp,
+extern int ifx_ssc_init(void);
+extern int ifx_ssc_open(struct inode *inode, struct file *filp);
+extern int ifx_ssc_close(struct inode *inode, struct file *filp);
+extern void ifx_ssc_cleanup_module(void);
+extern int ifx_ssc_ioctl(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long data);
-extern ssize_t ifx_ssc_kwrite (int port, const char *kbuf, size_t len);
-extern ssize_t ifx_ssc_kread (int port, char *kbuf, size_t len);
+extern ssize_t ifx_ssc_kwrite(int port, const char *kbuf, size_t len);
+extern ssize_t ifx_ssc_kread(int port, char *kbuf, size_t len);
-extern int ifx_ssc_cs_low (unsigned int pin);
-extern int ifx_ssc_cs_high (unsigned int pin);
-extern int ifx_ssc_txrx (char *tx_buf, unsigned int tx_len, char *rx_buf, unsigned int rx_len);
-extern int ifx_ssc_tx (char *tx_buf, unsigned int tx_len);
-extern int ifx_ssc_rx (char *rx_buf, unsigned int rx_len);
+extern int ifx_ssc_cs_low(unsigned int pin);
+extern int ifx_ssc_cs_high(unsigned int pin);
+extern int ifx_ssc_txrx(char *tx_buf, unsigned int tx_len, char *rx_buf, unsigned int rx_len);
+extern int ifx_ssc_tx(char *tx_buf, unsigned int tx_len);
+extern int ifx_ssc_rx(char *rx_buf, unsigned int rx_len);
#define EEPROM_CS IFX_SSC_WHBGPOSTAT_OUT0_POS
@@ -88,8 +88,7 @@ extern int ifx_ssc_rx (char *rx_buf, unsigned int rx_len);
#define EEPROM_PAGE_SIZE 4
#define EEPROM_SIZE 512
-static int
-eeprom_rdsr (void)
+static int eeprom_rdsr(void)
{
int ret = 0;
unsigned char cmd = EEPROM_RDSR;
@@ -108,15 +107,13 @@ eeprom_rdsr (void)
return ret;
}
-void
-eeprom_wip_over (void)
+void eeprom_wip_over(void)
{
while (eeprom_rdsr())
- printk("waiting for eeprom\n");
+ printk(KERN_INFO "waiting for eeprom\n");
}
-static int
-eeprom_wren (void)
+static int eeprom_wren(void)
{
unsigned char cmd = EEPROM_WREN;
int ret = 0;
@@ -136,8 +133,7 @@ eeprom_wren (void)
return ret;
}
-static int
-eeprom_wrsr (void)
+static int eeprom_wrsr(void)
{
int ret = 0;
unsigned char cmd[2];
@@ -146,9 +142,8 @@ eeprom_wrsr (void)
cmd[0] = EEPROM_WRSR;
cmd[1] = 0;
- if ((ret = eeprom_wren()))
- {
- printk ("eeprom_wren fails\n");
+ if ((ret = eeprom_wren())) {
+ printk(KERN_ERR "eeprom_wren fails\n");
goto out1;
}
@@ -171,23 +166,21 @@ eeprom_wrsr (void)
return ret;
out:
- local_irq_restore (flag);
- eeprom_wip_over ();
+ local_irq_restore(flag);
+ eeprom_wip_over();
out1:
return ret;
}
-static int
-eeprom_read (unsigned int addr, unsigned char *buf, unsigned int len)
+static int eeprom_read(unsigned int addr, unsigned char *buf, unsigned int len)
{
int ret = 0;
unsigned char write_buf[2];
unsigned int eff = 0;
unsigned long flag;
- while (1)
- {
+ while (1) {
eeprom_wip_over();
eff = EEPROM_PAGE_SIZE - (addr % EEPROM_PAGE_SIZE);
eff = (eff < len) ? eff : len;
@@ -196,13 +189,13 @@ eeprom_read (unsigned int addr, unsigned char *buf, unsigned int len)
if ((ret = ifx_ssc_cs_low(EEPROM_CS)) < 0)
goto out;
- write_buf[0] = EEPROM_READ | ((unsigned char) ((addr & 0x100) >> 5));
+ write_buf[0] = EEPROM_READ | ((unsigned char)((addr & 0x100) >> 5));
write_buf[1] = (addr & 0xff);
- if ((ret = ifx_ssc_txrx (write_buf, 2, buf, eff)) != eff)
- {
- printk("ssc_txrx fails %d\n", ret);
- ifx_ssc_cs_high (EEPROM_CS);
+ ret = ifx_ssc_txrx(write_buf, 2, buf, eff);
+ if (ret != eff) {
+ printk(KERN_ERR "ssc_txrx fails %d\n", ret);
+ ifx_ssc_cs_high(EEPROM_CS);
goto out;
}
@@ -210,7 +203,8 @@ eeprom_read (unsigned int addr, unsigned char *buf, unsigned int len)
len -= ret;
addr += ret;
- if ((ret = ifx_ssc_cs_high(EEPROM_CS)))
+ ret = ifx_ssc_cs_high(EEPROM_CS);
+ if (ret)
goto out;
local_irq_restore(flag);
@@ -220,13 +214,12 @@ eeprom_read (unsigned int addr, unsigned char *buf, unsigned int len)
}
out:
- local_irq_restore (flag);
+ local_irq_restore(flag);
out2:
return ret;
}
-static int
-eeprom_write (unsigned int addr, unsigned char *buf, unsigned int len)
+static int eeprom_write(unsigned int addr, unsigned char *buf, unsigned int len)
{
int ret = 0;
unsigned int eff = 0;
@@ -234,23 +227,21 @@ eeprom_write (unsigned int addr, unsigned char *buf, unsigned int len)
int i;
unsigned char rx_buf[EEPROM_PAGE_SIZE];
- while (1)
- {
+ while (1) {
eeprom_wip_over();
- if ((ret = eeprom_wren()))
- {
- printk("eeprom_wren fails\n");
+ if ((ret = eeprom_wren())) {
+ printk(KERN_ERR "eeprom_wren fails\n");
goto out;
}
- write_buf[0] = EEPROM_WRITE | ((unsigned char) ((addr & 0x100) >> 5));
+ write_buf[0] = EEPROM_WRITE | ((unsigned char)((addr & 0x100) >> 5));
write_buf[1] = (addr & 0xff);
eff = EEPROM_PAGE_SIZE - (addr % EEPROM_PAGE_SIZE);
eff = (eff < len) ? eff : len;
- printk("EEPROM Write:\n");
+ printk(KERN_INFO "EEPROM Write:\n");
for (i = 0; i < eff; i++) {
printk("%2x ", buf[i]);
if ((i % 16) == 15)
@@ -261,16 +252,14 @@ eeprom_write (unsigned int addr, unsigned char *buf, unsigned int len)
if ((ret = ifx_ssc_cs_low(EEPROM_CS)))
goto out;
- if ((ret = ifx_ssc_tx (write_buf, 2)) < 0)
- {
- printk("ssc_tx fails %d\n", ret);
+ if ((ret = ifx_ssc_tx(write_buf, 2)) < 0) {
+ printk(KERN_ERR "ssc_tx fails %d\n", ret);
ifx_ssc_cs_high(EEPROM_CS);
goto out;
}
- if ((ret = ifx_ssc_tx (buf, eff)) != eff)
- {
- printk("ssc_tx fails %d\n", ret);
+ if ((ret = ifx_ssc_tx(buf, eff)) != eff) {
+ printk(KERN_ERR "ssc_tx fails %d\n", ret);
ifx_ssc_cs_high(EEPROM_CS);
goto out;
}
@@ -279,16 +268,14 @@ eeprom_write (unsigned int addr, unsigned char *buf, unsigned int len)
len -= ret;
addr += ret;
- if ((ret = ifx_ssc_cs_high (EEPROM_CS)))
+ if ((ret = ifx_ssc_cs_high(EEPROM_CS)))
goto out;
- printk ("<==");
+ printk(KERN_INFO "<==");
eeprom_read((addr - eff), rx_buf, eff);
for (i = 0; i < eff; i++)
- {
- printk ("[%x]", rx_buf[i]);
- }
- printk ("\n");
+ printk("[%x]", rx_buf[i]);
+ printk("\n");
if (len <= 0)
break;
@@ -298,81 +285,71 @@ out:
return ret;
}
-int
-ifxmips_eeprom_open (struct inode *inode, struct file *filp)
+int ifxmips_eeprom_open(struct inode *inode, struct file *filp)
{
filp->f_pos = 0;
return 0;
}
-int
-ifxmips_eeprom_close (struct inode *inode, struct file *filp)
+int ifxmips_eeprom_close(struct inode *inode, struct file *filp)
{
return 0;
}
-int
-ifxmips_eeprom_ioctl (struct inode *inode, struct file *filp, unsigned int cmd, unsigned long data)
+int ifxmips_eeprom_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long data)
{
return 0;
}
-ssize_t
-ifxmips_eeprom_read (char *buf, size_t len, unsigned int addr)
+ssize_t ifxmips_eeprom_read(char *buf, size_t len, unsigned int addr)
{
int ret = 0;
unsigned int data;
- printk("addr:=%d\n", addr);
- printk("len:=%d\n", len);
+ printk(KERN_INFO "addr:=%d\n", addr);
+ printk(KERN_INFO "len:=%d\n", len);
- if ((addr + len) > EEPROM_SIZE)
- {
- printk("invalid len\n");
+ if ((addr + len) > EEPROM_SIZE) {
+ printk(KERN_ERR "invalid len\n");
addr = 0;
len = EEPROM_SIZE / 2;
}
- if ((ret = ifx_ssc_open((struct inode *) 0, NULL)))
- {
- printk("ifxmips_eeprom_open fails\n");
+ if ((ret = ifx_ssc_open((struct inode *)0, NULL))) {
+ printk(KERN_ERR "ifxmips_ssc_open fails\n");
goto out;
}
data = (unsigned int)IFX_SSC_MODE_RXTX;
- if ((ret = ifx_ssc_ioctl((struct inode *) 0, NULL, IFX_SSC_RXTX_MODE_SET, (unsigned long) &data)))
- {
- printk("set RXTX mode fails\n");
+ if ((ret = ifx_ssc_ioctl((struct inode *)0, NULL, IFX_SSC_RXTX_MODE_SET, (unsigned long) &data))) {
+ printk(KERN_ERR "set RXTX mode fails\n");
goto out;
}
- if ((ret = eeprom_wrsr()))
- {
- printk("EEPROM reset fails\n");
+ if ((ret = eeprom_wrsr())) {
+ printk(KERN_ERR "EEPROM reset fails\n");
goto out;
}
- if ((ret = eeprom_read(addr, buf, len)))
- {
- printk("eeprom read fails\n");
+ if ((ret = eeprom_read(addr, buf, len))) {
+ printk(KERN_ERR "eeprom read fails\n");
goto out;
}
out:
- if (ifx_ssc_close((struct inode *) 0, NULL))
- printk("ifxmips_eeprom_close fails\n");
+ if (ifx_ssc_close((struct inode *)0, NULL))
+ printk(KERN_ERR "ifxmips_ssc_close fails\n");
return len;
}
EXPORT_SYMBOL(ifxmips_eeprom_read);
-static ssize_t
-ifxmips_eeprom_fops_read (struct file *filp, char *ubuf, size_t len, loff_t * off)
+static ssize_t ifxmips_eeprom_fops_read(struct file *filp, char *ubuf, size_t len, loff_t *off)
{
int ret = 0;
unsigned char ssc_rx_buf[EEPROM_SIZE];
- long flag;
+ unsigned long flag;
if (*off >= EEPROM_SIZE)
return 0;
@@ -385,15 +362,13 @@ ifxmips_eeprom_fops_read (struct file *filp, char *ubuf, size_t len, loff_t * of
local_irq_save(flag);
- if ((ret = ifxmips_eeprom_read(ssc_rx_buf, len, *off)) < 0)
- {
- printk("read fails, err=%x\n", ret);
+ if ((ret = ifxmips_eeprom_read(ssc_rx_buf, len, *off)) < 0) {
+ printk(KERN_ERR "read fails, err=%x\n", ret);
local_irq_restore(flag);
return ret;
}
- if (copy_to_user((void*)ubuf, ssc_rx_buf, ret) != 0)
- {
+ if (copy_to_user((void *)ubuf, ssc_rx_buf, ret) != 0) {
local_irq_restore(flag);
ret = -EFAULT;
}
@@ -404,46 +379,42 @@ ifxmips_eeprom_fops_read (struct file *filp, char *ubuf, size_t len, loff_t * of
return len;
}
-ssize_t
-ifxmips_eeprom_write (char *buf, size_t len, unsigned int addr)
+ssize_t ifxmips_eeprom_write(char *buf, size_t len, unsigned int addr)
{
int ret = 0;
unsigned int data;
- if ((ret = ifx_ssc_open ((struct inode *) 0, NULL)))
- {
- printk ("ifxmips_eeprom_open fails\n");
+ if ((ret = ifx_ssc_open((struct inode *)0, NULL))) {
+ printk(KERN_ERR "ifxmips_ssc_open fails\n");
goto out;
}
data = (unsigned int) IFX_SSC_MODE_RXTX;
- if ((ret = ifx_ssc_ioctl ((struct inode *) 0, NULL, IFX_SSC_RXTX_MODE_SET, (unsigned long) &data)))
- {
- printk ("set RXTX mode fails\n");
+ if ((ret = ifx_ssc_ioctl((struct inode *)0, NULL, IFX_SSC_RXTX_MODE_SET, (unsigned long) &data))) {
+ printk(KERN_ERR "set RXTX mode fails\n");
goto out;
}
- if ((ret = eeprom_wrsr ())) {
- printk ("EEPROM reset fails\n");
+ if ((ret = eeprom_wrsr())) {
+ printk(KERN_ERR "EEPROM reset fails\n");
goto out;
}
- if ((ret = eeprom_write (addr, buf, len))) {
- printk ("eeprom write fails\n");
+ if ((ret = eeprom_write(addr, buf, len))) {
+ printk(KERN_ERR "eeprom write fails\n");
goto out;
}
out:
- if (ifx_ssc_close ((struct inode *) 0, NULL))
- printk ("ifxmips_eeprom_close fails\n");
+ if (ifx_ssc_close((struct inode *)0, NULL))
+ printk(KERN_ERR "ifxmips_ssc_close fails\n");
return ret;
}
EXPORT_SYMBOL(ifxmips_eeprom_write);
-static ssize_t
-ifxmips_eeprom_fops_write (struct file *filp, const char *ubuf, size_t len, loff_t * off)
+static ssize_t ifxmips_eeprom_fops_write(struct file *filp, const char *ubuf, size_t len, loff_t *off)
{
int ret = 0;
unsigned char ssc_tx_buf[EEPROM_SIZE];
@@ -454,10 +425,10 @@ ifxmips_eeprom_fops_write (struct file *filp, const char *ubuf, size_t len, loff
if (len + *off > EEPROM_SIZE)
len = EEPROM_SIZE - *off;
- if ((ret = copy_from_user (ssc_tx_buf, ubuf, len)))
+ if ((ret = copy_from_user(ssc_tx_buf, ubuf, len)))
return EFAULT;
- ret = ifxmips_eeprom_write (ssc_tx_buf, len, *off);
+ ret = ifxmips_eeprom_write(ssc_tx_buf, len, *off);
if (ret > 0)
*off = ret;
@@ -465,8 +436,7 @@ ifxmips_eeprom_fops_write (struct file *filp, const char *ubuf, size_t len, loff
return ret;
}
-loff_t
-ifxmips_eeprom_llseek (struct file * filp, loff_t off, int whence)
+loff_t ifxmips_eeprom_llseek(struct file *filp, loff_t off, int whence)
{
loff_t newpos;
switch (whence) {
@@ -491,51 +461,47 @@ ifxmips_eeprom_llseek (struct file * filp, loff_t off, int whence)
}
static struct file_operations ifxmips_eeprom_fops = {
- owner:THIS_MODULE,
- llseek:ifxmips_eeprom_llseek,
- read:ifxmips_eeprom_fops_read,
- write:ifxmips_eeprom_fops_write,
- ioctl:ifxmips_eeprom_ioctl,
- open:ifxmips_eeprom_open,
- release:ifxmips_eeprom_close,
+ .owner = THIS_MODULE,
+ .llseek = ifxmips_eeprom_llseek,
+ .read = ifxmips_eeprom_fops_read,
+ .write = ifxmips_eeprom_fops_write,
+ .ioctl = ifxmips_eeprom_ioctl,
+ .open = ifxmips_eeprom_open,
+ .release = ifxmips_eeprom_close,
};
-int __init
-ifxmips_eeprom_init (void)
+int __init ifxmips_eeprom_init(void)
{
int ret = 0;
ifxmips_eeprom_maj = register_chrdev(0, "eeprom", &ifxmips_eeprom_fops);
- if (ifxmips_eeprom_maj < 0)
- {
- printk("failed to register eeprom device\n");
+ if (ifxmips_eeprom_maj < 0) {
+ printk(KERN_ERR "failed to register eeprom device\n");
ret = -EINVAL;
-
+
goto out;
}
- printk("ifxmips_eeprom : /dev/eeprom mayor %d\n", ifxmips_eeprom_maj);
+ printk(KERN_INFO "ifxmips_eeprom : /dev/eeprom mayor %d\n", ifxmips_eeprom_maj);
out:
return ret;
}
-void __exit
-ifxmips_eeprom_cleanup_module (void)
+void __exit ifxmips_eeprom_cleanup_module(void)
{
- /*if (unregister_chrdev (ifxmips_eeprom_maj, "eeprom")) {
- printk ("Unable to unregister major %d for the EEPROM\n",
+ /*if (unregister_chrdev(ifxmips_eeprom_maj, "eeprom")) {
+ printk(KERN_ERR "Unable to unregister major %d for the EEPROM\n",
maj);
}*/
}
-module_exit (ifxmips_eeprom_cleanup_module);
-module_init (ifxmips_eeprom_init);
-
-MODULE_LICENSE ("GPL");
-MODULE_AUTHOR ("Peng Liu");
-MODULE_DESCRIPTION ("IFAP EEPROM driver");
-MODULE_SUPPORTED_DEVICE ("ifxmips_eeprom");
+module_exit(ifxmips_eeprom_cleanup_module);
+module_init(ifxmips_eeprom_init);
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Peng Liu");
+MODULE_DESCRIPTION("IFAP EEPROM driver");
+MODULE_SUPPORTED_DEVICE("ifxmips_eeprom");
diff --git a/target/linux/ifxmips/files/drivers/char/ifxmips_ssc.c b/target/linux/ifxmips/files/drivers/char/ifxmips_ssc.c
index 35b32e852..5d6135602 100644
--- a/target/linux/ifxmips/files/drivers/char/ifxmips_ssc.c
+++ b/target/linux/ifxmips/files/drivers/char/ifxmips_ssc.c
@@ -13,17 +13,19 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
- * Copyright (C) 2006 infineon
- * Copyright (C) 2007 John Crispin <blogic@openwrt.org>
+ * Copyright(C) 2006 infineon
+ * Copyright(C) 2007 John Crispin <blogic@openwrt.org>
*
*/
-// ### TO DO: general issues:
-// - power management
-// - interrupt handling (direct/indirect)
-// - pin/mux-handling (just overall concept due to project dependency)
-// - multiple instances capability
-// - slave functionality
+/*
+### TO DO: general issues:
+ - power management
+ - interrupt handling (direct/indirect)
+ - pin/mux-handling (just overall concept due to project dependency)
+ - multiple instances capability
+ - slave functionality
+*/
#include <linux/module.h>
#include <linux/errno.h>
@@ -42,24 +44,23 @@
#include <linux/delay.h>
#include <linux/spinlock.h>
#include <linux/slab.h>
-
-#include <asm/system.h>
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/uaccess.h>
-#include <asm/bitops.h>
+#include <linux/io.h>
+#include <linux/irq.h>
+#include <linux/uaccess.h>
+#include <linux/bitops.h>
#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/version.h>
+#include <asm/system.h>
#include <asm/ifxmips/ifxmips.h>
#include <asm/ifxmips/ifxmips_irq.h>
#include <asm/ifxmips/ifx_ssc_defines.h>
#include <asm/ifxmips/ifx_ssc.h>
/* allow the user to set the major device number */
-static int maj = 0;
+static int maj;
/*
* This is the per-channel data structure containing pointers, flags
@@ -69,28 +70,25 @@ static int maj = 0;
static struct ifx_ssc_port *isp;
/* other forward declarations */
-static unsigned int ifx_ssc_get_kernel_clk (struct ifx_ssc_port *info);
-static void tx_int (struct ifx_ssc_port *);
+static unsigned int ifx_ssc_get_kernel_clk(struct ifx_ssc_port *info);
+static void tx_int(struct ifx_ssc_port *);
-extern unsigned int ifxmips_get_fpi_hz (void);
-extern void ifxmips_mask_and_ack_irq (unsigned int irq_nr);
+extern unsigned int ifxmips_get_fpi_hz(void);
+extern void ifxmips_mask_and_ack_irq(unsigned int irq_nr);
-static inline unsigned int
-ifx_ssc_get_kernel_clk (struct ifx_ssc_port *info)
+static inline unsigned int ifx_ssc_get_kernel_clk(struct ifx_ssc_port *info)
{
unsigned int rmc;
rmc = (ifxmips_r32(IFXMIPS_SSC_CLC) & IFX_CLC_RUN_DIVIDER_MASK) >> IFX_CLC_RUN_DIVIDER_OFFSET;
- if (rmc == 0)
- {
- printk ("ifx_ssc_get_kernel_clk rmc==0 \n");
+ if (rmc == 0) {
+ printk("ifx_ssc_get_kernel_clk rmc==0 \n");
return 0;
}
- return ifxmips_get_fpi_hz () / rmc;
+ return ifxmips_get_fpi_hz() / rmc;
}
-inline static void
-rx_int (struct ifx_ssc_port *info)
+static inline void rx_int(struct ifx_ssc_port *info)
{
int fifo_fill_lev, bytes_in_buf, i;
unsigned long tmp_val;
@@ -99,9 +97,9 @@ rx_int (struct ifx_ssc_port *info)
/* number of words waiting in the RX FIFO */
fifo_fill_lev = (ifxmips_r32(IFXMIPS_SSC_FSTAT) & IFX_SSC_FSTAT_RECEIVED_WORDS_MASK) >> IFX_SSC_FSTAT_RECEIVED_WORDS_OFFSET;
bytes_in_buf = info->rxbuf_end - info->rxbuf_ptr;
- // transfer with 32 bits per entry
+ /* transfer with 32 bits per entry */
while ((bytes_in_buf >= 4) && (fifo_fill_lev > 0)) {
- tmp_ptr = (unsigned long *) info->rxbuf_ptr;
+ tmp_ptr = (unsigned long *)info->rxbuf_ptr;
*tmp_ptr = ifxmips_r32(IFXMIPS_SSC_RB);
info->rxbuf_ptr += 4;
info->stats.rxBytes += 4;
@@ -109,7 +107,7 @@ rx_int (struct ifx_ssc_port *info)
bytes_in_buf -= 4;
}
- // now do the rest as mentioned in STATE.RXBV
+ /* now do the rest as mentioned in STATE.RXBV */
while ((bytes_in_buf > 0) && (fifo_fill_lev > 0)) {
rx_valid_cnt = (ifxmips_r32(IFXMIPS_SSC_STATE) & IFX_SSC_STATE_RX_BYTE_VALID_MASK) >> IFX_SSC_STATE_RX_BYTE_VALID_OFFSET;
if (rx_valid_cnt == 0)
@@ -120,8 +118,7 @@ rx_int (struct ifx_ssc_port *info)
tmp_val = ifxmips_r32(IFXMIPS_SSC_RB);
- for (i = 0; i < rx_valid_cnt; i++)
- {
+ for (i = 0; i < rx_valid_cnt; i++) {
*info->rxbuf_ptr = (tmp_val >> (8 * (rx_valid_cnt - i - 1))) & 0xff;
bytes_in_buf--;
info->rxbuf_ptr++;
@@ -129,13 +126,11 @@ rx_int (struct ifx_ssc_port *info)
info->stats.rxBytes += rx_valid_cnt;
}
- // check if transfer is complete
- if (info->rxbuf_ptr >= info->rxbuf_end)
- {
+ /* check if transfer is complete */
+ if (info->rxbuf_ptr >= info->rxbuf_end) {
disable_irq(IFXMIPS_SSC_RIR);
- wake_up_interruptible (&info->rwait);
- } else if ((info->opts.modeRxTx == IFX_SSC_MODE_RX) && (ifxmips_r32(IFXMIPS_SSC_RXCNT) == 0))
- {
+ wake_up_interruptible(&info->rwait);
+ } else if ((info->opts.modeRxTx == IFX_SSC_MODE_RX) && (ifxmips_r32(IFXMIPS_SSC_RXCNT) == 0)) {
if (info->rxbuf_end - info->rxbuf_ptr < IFX_SSC_RXREQ_BLOCK_SIZE)
ifxmips_w32((info->rxbuf_end - info->rxbuf_ptr) << IFX_SSC_RXREQ_RXCOUNT_OFFSET, IFXMIPS_SSC_RXREQ);
else
@@ -143,13 +138,12 @@ rx_int (struct ifx_ssc_port *info)
}
}
-inline static void
-tx_int (struct ifx_ssc_port *info)
+static inline void tx_int(struct ifx_ssc_port *info)
{
int fifo_space, fill, i;
fifo_space = ((ifxmips_r32(IFXMIPS_SSC_ID) & IFX_SSC_PERID_TXFS_MASK) >> IFX_SSC_PERID_TXFS_OFFSET)
- - ((ifxmips_r32(IFXMIPS_SSC_FSTAT) & IFX_SSC_FSTAT_TRANSMIT_WORDS_MASK) >> IFX_SSC_FSTAT_TRANSMIT_WORDS_OFFSET);
+ -((ifxmips_r32(IFXMIPS_SSC_FSTAT) & IFX_SSC_FSTAT_TRANSMIT_WORDS_MASK) >> IFX_SSC_FSTAT_TRANSMIT_WORDS_OFFSET);
if (fifo_space == 0)
return;
@@ -159,71 +153,64 @@ tx_int (struct ifx_ssc_port *info)
if (fill > fifo_space * 4)
fill = fifo_space * 4;
- for (i = 0; i < fill / 4; i++)
- {
- // at first 32 bit access
- ifxmips_w32(*(UINT32 *) info->txbuf_ptr, IFXMIPS_SSC_TB);
+ for (i = 0; i < fill / 4; i++) {
+ /* at first 32 bit access */
+ ifxmips_w32(*(UINT32 *)info->txbuf_ptr, IFXMIPS_SSC_TB);
info->txbuf_ptr += 4;
}
fifo_space -= fill / 4;
info->stats.txBytes += fill & ~0x3;
fill &= 0x3;
- if ((fifo_space > 0) & (fill > 1))
- {
- // trailing 16 bit access
- WRITE_PERIPHERAL_REGISTER_16 (*(UINT16 *) info->txbuf_ptr, info->mapbase + IFX_SSC_TB);
+ if ((fifo_space > 0) & (fill > 1)) {
+ /* trailing 16 bit access */
+ WRITE_PERIPHERAL_REGISTER_16(*(UINT16 *)info->txbuf_ptr, info->mapbase + IFX_SSC_TB);
info->txbuf_ptr += 2;
info->stats.txBytes += 2;
fifo_space--;
fill -= 2;
}
- if ((fifo_space > 0) & (fill > 0))
- {
- // trailing 8 bit access
- WRITE_PERIPHERAL_REGISTER_8 (*(UINT8 *) info->txbuf_ptr, info->mapbase + IFX_SSC_TB);
+ if ((fifo_space > 0) & (fill > 0)) {
+ /* trailing 8 bit access */
+ WRITE_PERIPHERAL_REGISTER_8(*(UINT8 *)info->txbuf_ptr, info->mapbase + IFX_SSC_TB);
info->txbuf_ptr++;
info->stats.txBytes++;
}
- // check if transmission complete
- if (info->txbuf_ptr >= info->txbuf_end)
- {
+ /* check if transmission complete */
+ if (info->txbuf_ptr >= info->txbuf_end) {
disable_irq(IFXMIPS_SSC_TIR);
- kfree (info->txbuf);
+ kfree(info->txbuf);
info->txbuf = NULL;
}
}
-irqreturn_t
-ifx_ssc_rx_int (int irq, void *dev_id)
+irqreturn_t ifx_ssc_rx_int(int irq, void *dev_id)
{
- struct ifx_ssc_port *info = (struct ifx_ssc_port *) dev_id;
- rx_int (info);
+ struct ifx_ssc_port *info = (struct ifx_ssc_port *)dev_id;
+ rx_int(info);
return IRQ_HANDLED;
}
-irqreturn_t
-ifx_ssc_tx_int (int irq, void *dev_id)
+irqreturn_t ifx_ssc_tx_int(int irq, void *dev_id)
{
- struct ifx_ssc_port *info = (struct ifx_ssc_port *) dev_id;
- tx_int (info);
+ struct ifx_ssc_port *info = (struct ifx_ssc_port *)dev_id;
+ tx_int(info);
return IRQ_HANDLED;
}
-irqreturn_t
-ifx_ssc_err_int (int irq, void *dev_id)
+irqreturn_t ifx_ssc_err_int(int irq, void *dev_id)
{
- struct ifx_ssc_port *info = (struct ifx_ssc_port *) dev_id;
+ struct ifx_ssc_port *info = (struct ifx_ssc_port *)dev_id;
unsigned int state;
unsigned int write_back = 0;
unsigned long flags;
- local_irq_save (flags);
+ local_irq_save(flags);
state = ifxmips_r32(IFXMIPS_SSC_STATE);
if ((state & IFX_SSC_STATE_RX_UFL) != 0) {
@@ -254,54 +241,53 @@ ifx_ssc_err_int (int irq, void *dev_id)
if (write_back)
ifxmips_w32(write_back, IFXMIPS_SSC_WHBSTATE);
- local_irq_restore (flags);
+ local_irq_restore(flags);
return IRQ_HANDLED;
}
-static void
-ifx_ssc_abort (struct ifx_ssc_port *info)
+static void ifx_ssc_abort(struct ifx_ssc_port *info)
{
unsigned long flags;
bool enabled;
- local_irq_save (flags);
+ local_irq_save(flags);
disable_irq(IFXMIPS_SSC_RIR);
disable_irq(IFXMIPS_SSC_TIR);
disable_irq(IFXMIPS_SSC_EIR);
- local_irq_restore (flags);
+ local_irq_restore(flags);
- // disable SSC (also aborts a receive request!)
- // ### TO DO: Perhaps it's better to abort after the receiption of a
- // complete word. The disable cuts the transmission immediatly and
- // releases the chip selects. This could result in unpredictable
- // behavior of connected external devices!
+ /* disable SSC(also aborts a receive request!) */
+ /* ### TO DO: Perhaps it's better to abort after the receiption of a
+ complete word. The disable cuts the transmission immediatly and
+ releases the chip selects. This could result in unpredictable
+ behavior of connected external devices!
+ */
enabled = (ifxmips_r32(IFXMIPS_SSC_STATE) & IFX_SSC_STATE_IS_ENABLED) != 0;
ifxmips_w32(IFX_SSC_WHBSTATE_CLR_ENABLE, IFXMIPS_SSC_WHBSTATE);
- // flush fifos
+ /* flush fifos */
ifxmips_w32(IFX_SSC_XFCON_FIFO_FLUSH, IFXMIPS_SSC_TXFCON);
ifxmips_w32(IFX_SSC_XFCON_FIFO_FLUSH, IFXMIPS_SSC_RXFCON);
- // free txbuf
- if (info->txbuf != NULL)
- {
- kfree (info->txbuf);
+ /* free txbuf */
+ if (info->txbuf != NULL) {
+ kfree(info->txbuf);
info->txbuf = NULL;
}
- // wakeup read process
+ /* wakeup read process */
if (info->rxbuf != NULL)
- wake_up_interruptible (&info->rwait);
+ wake_up_interruptible(&info->rwait);
- // clear pending int's
+ /* clear pending int's */
ifxmips_mask_and_ack_irq(IFXMIPS_SSC_RIR);
ifxmips_mask_and_ack_irq(IFXMIPS_SSC_TIR);
ifxmips_mask_and_ack_irq(IFXMIPS_SSC_EIR);
- // clear error flags
+ /* clear error flags */
ifxmips_w32(IFX_SSC_WHBSTATE_CLR_ALL_ERROR, IFXMIPS_SSC_WHBSTATE);
if (enabled)
@@ -313,19 +299,17 @@ ifx_ssc_abort (struct ifx_ssc_port *info)
* This routine is called whenever a port is opened. It enforces
* exclusive opening of a port and enables interrupts, etc.
*/
-int
-ifx_ssc_open (struct inode *inode, struct file *filp)
+int ifx_ssc_open(struct inode *inode, struct file *filp)
{
struct ifx_ssc_port *info;
int line;
int from_kernel = 0;
- if ((inode == (struct inode *) 0) || (inode == (struct inode *) 1)) {
+ if ((inode == (struct inode *)0) || (inode == (struct inode *)1)) {
from_kernel = 1;
line = (int) inode;
- } else {
- line = MINOR (filp->f_dentry->d_inode->i_rdev);
- }
+ } else
+ line = MINOR(filp->f_dentry->d_inode->i_rdev);
/* don't open more minor devices than we can support */
if (line < 0 || line >= PORT_CNT)
@@ -353,7 +337,7 @@ ifx_ssc_open (struct inode *inode, struct file *filp)
/* clear all error bits */
ifxmips_w32(IFX_SSC_WHBSTATE_CLR_ALL_ERROR, IFXMIPS_SSC_WHBSTATE);
- // clear pending interrupts
+ /* clear pending interrupts */
ifxmips_mask_and_ack_irq(IFXMIPS_SSC_RIR);
ifxmips_mask_and_ack_irq(IFXMIPS_SSC_TIR);
ifxmips_mask_and_ack_irq(IFXMIPS_SSC_EIR);
@@ -364,16 +348,15 @@ ifx_ssc_open (struct inode *inode, struct file *filp)
}
EXPORT_SYMBOL(ifx_ssc_open);
-int
-ifx_ssc_close (struct inode *inode, struct file *filp)
+int ifx_ssc_close(struct inode *inode, struct file *filp)
{
struct ifx_ssc_port *info;
int idx;
- if ((inode == (struct inode *) 0) || (inode == (struct inode *) 1))
+ if ((inode == (struct inode *)0) || (inode == (struct inode *)1))
idx = (int) inode;
else
- idx = MINOR (filp->f_dentry->d_inode->i_rdev);
+ idx = MINOR(filp->f_dentry->d_inode->i_rdev);
if (idx < 0 || idx >= PORT_CNT)
return -ENXIO;
@@ -392,26 +375,25 @@ ifx_ssc_close (struct inode *inode, struct file *filp)
}
EXPORT_SYMBOL(ifx_ssc_close);
-static ssize_t
-ifx_ssc_read_helper_poll (struct ifx_ssc_port *info, char *buf, size_t len, int from_kernel)
+static ssize_t ifx_ssc_read_helper_poll(struct ifx_ssc_port *info, char *buf,
+ size_t len, int from_kernel)
{
ssize_t ret_val;
unsigned long flags;
if (info->opts.modeRxTx == IFX_SSC_MODE_TX)
return -EFAULT;
- local_irq_save (flags);
+ local_irq_save(flags);
info->rxbuf_ptr = info->rxbuf;
info->rxbuf_end = info->rxbuf + len;
- local_irq_restore (flags);
+ local_irq_restore(flags);
/* Vinetic driver always works in IFX_SSC_MODE_RXTX */
/* TXRX in poll mode */
- while (info->rxbuf_ptr < info->rxbuf_end)
- {
+ while (info->rxbuf_ptr < info->rxbuf_end) {
if (info->txbuf_ptr < info->txbuf_end)
- tx_int (info);
+ tx_int(info);
- rx_int (info);
+ rx_int(info);
};
ret_val = info->rxbuf_ptr - info->rxbuf;
@@ -419,31 +401,29 @@ ifx_ssc_read_helper_poll (struct ifx_ssc_port *info, char *buf, size_t len, int
return ret_val;
}
-static ssize_t
-ifx_ssc_read_helper (struct ifx_ssc_port *info, char *buf, size_t len, int from_kernel)
+static ssize_t ifx_ssc_read_helper(struct ifx_ssc_port *info, char *buf,
+ size_t len, int from_kernel)
{
ssize_t ret_val;
unsigned long flags;
- DECLARE_WAITQUEUE (wait, current);
+ DECLARE_WAITQUEUE(wait, current);
if (info->opts.modeRxTx == IFX_SSC_MODE_TX)
return -EFAULT;
- local_irq_save (flags);
+ local_irq_save(flags);
info->rxbuf_ptr = info->rxbuf;
info->rxbuf_end = info->rxbuf + len;
- if (info->opts.modeRxTx == IFX_SSC_MODE_RXTX)
- {
- if ((info->txbuf == NULL) || (info->txbuf != info->txbuf_ptr) || (info->txbuf_end != len + info->txbuf))
- {
- local_irq_restore (flags);
- printk ("IFX SSC - %s: write must be called before calling " "read in combined RX/TX!\n", __func__);
+ if (info->opts.modeRxTx == IFX_SSC_MODE_RXTX) {
+ if ((info->txbuf == NULL) || (info->txbuf != info->txbuf_ptr) || (info->txbuf_end != len + info->txbuf)) {
+ local_irq_restore(flags);
+ printk("IFX SSC - %s: write must be called before calling " "read in combined RX/TX!\n", __func__);
return -EFAULT;
}
local_irq_restore(flags);
- tx_int (info);
+ tx_int(info);
if (info->txbuf_ptr < info->txbuf_end)
enable_irq(IFXMIPS_SSC_TIR);
@@ -460,18 +440,17 @@ ifx_ssc_read_helper (struct ifx_ssc_port *info, char *buf, size_t len, int from_
ifxmips_w32(IFX_SSC_RXREQ_BLOCK_SIZE << IFX_SSC_RXREQ_RXCOUNT_OFFSET, IFXMIPS_SSC_RXREQ);
}
- __add_wait_queue (&info->rwait, &wait);
- set_current_state (TASK_INTERRUPTIBLE);
+ __add_wait_queue(&info->rwait, &wait);
+ set_current_state(TASK_INTERRUPTIBLE);
do {
- local_irq_save (flags);
+ local_irq_save(flags);
if (info->rxbuf_ptr >= info->rxbuf_end)
break;
- local_irq_restore (flags);
+ local_irq_restore(flags);
- if (signal_pending (current))
- {
+ if (signal_pending(current)) {
ret_val = -ERESTARTSYS;
goto out;
}
@@ -479,38 +458,33 @@ ifx_ssc_read_helper (struct ifx_ssc_port *info, char *buf, size_t len, int from_
} while (1);
ret_val = info->rxbuf_ptr - info->rxbuf;
- local_irq_restore (flags);
+ local_irq_restore(flags);
out:
current->state = TASK_RUNNING;
- __remove_wait_queue (&info->rwait, &wait);
+ __remove_wait_queue(&info->rwait, &wait);
- return (ret_val);
+ return ret_val;
}
-static ssize_t
-ifx_ssc_write_helper (struct ifx_ssc_port *info, const char *buf,
- size_t len, int from_kernel)
+static ssize_t ifx_ssc_write_helper(struct ifx_ssc_port *info, const char *buf,
+ size_t len, int from_kernel)
{
if (info->opts.modeRxTx == IFX_SSC_MODE_RX)
return -EFAULT;
info->txbuf_ptr = info->txbuf;
info->txbuf_end = len + info->txbuf;
- if (info->opts.modeRxTx == IFX_SSC_MODE_TX)
- {
- tx_int (info);
+ if (info->opts.modeRxTx == IFX_SSC_MODE_TX) {
+ tx_int(info);
if (info->txbuf_ptr < info->txbuf_end)
- {
enable_irq(IFXMIPS_SSC_TIR);
- }
}
return len;
}
-ssize_t
-ifx_ssc_kread (int port, char *kbuf, size_t len)
+ssize_t ifx_ssc_kread(int port, char *kbuf, size_t len)
{
struct ifx_ssc_port *info;
ssize_t ret_val;
@@ -523,20 +497,18 @@ ifx_ssc_kread (int port, char *kbuf, size_t len)
info = &isp[port];
- if (info->rxbuf != NULL)
- {
- printk ("SSC device busy\n");
+ if (info->rxbuf != NULL) {
+ printk("SSC device busy\n");
return -EBUSY;
}
info->rxbuf = kbuf;
- if (info->rxbuf == NULL)
- {
- printk ("SSC device error\n");
+ if (info->rxbuf == NULL) {
+ printk("SSC device error\n");
return -EINVAL;
}
- ret_val = ifx_ssc_read_helper_poll (info, kbuf, len, 1);
+ ret_val = ifx_ssc_read_helper_poll(info, kbuf, len, 1);
info->rxbuf = NULL;
disable_irq(IFXMIPS_SSC_RIR);
@@ -545,8 +517,7 @@ ifx_ssc_kread (int port, char *kbuf, size_t len)
}
EXPORT_SYMBOL(ifx_ssc_kread);
-ssize_t
-ifx_ssc_kwrite (int port, const char *kbuf, size_t len)
+ssize_t ifx_ssc_kwrite(int port, const char *kbuf, size_t len)
{
struct ifx_ssc_port *info;
ssize_t ret_val;
@@ -559,13 +530,13 @@ ifx_ssc_kwrite (int port, const char *kbuf, size_t len)
info = &isp[port];
- // check if transmission in progress
+ /* check if transmission in progress */
if (info->txbuf != NULL)
return -EBUSY;
- info->txbuf = (char *) kbuf;
+ info->txbuf = (char *)kbuf;
- ret_val = ifx_ssc_write_helper (info, info->txbuf, len, 1);
+ ret_val = ifx_ssc_write_helper(info, info->txbuf, len, 1);
if (ret_val < 0)
info->txbuf = NULL;
@@ -574,72 +545,68 @@ ifx_ssc_kwrite (int port, const char *kbuf, size_t len)
}
EXPORT_SYMBOL(ifx_ssc_kwrite);
-static ssize_t
-ifx_ssc_read (struct file *filp, char *ubuf, size_t len, loff_t * off)
+static ssize_t ifx_ssc_read(struct file *filp, char *ubuf, size_t len, loff_t *off)
{
ssize_t ret_val;
int idx;
struct ifx_ssc_port *info;
- idx = MINOR (filp->f_dentry->d_inode->i_rdev);
+ idx = MINOR(filp->f_dentry->d_inode->i_rdev);
info = &isp[idx];
if (info->rxbuf != NULL)
return -EBUSY;
- info->rxbuf = kmalloc (len + 3, GFP_KERNEL);
+ info->rxbuf = kmalloc(len + 3, GFP_KERNEL);
if (info->rxbuf == NULL)
return -ENOMEM;
- ret_val = ifx_ssc_read_helper (info, info->rxbuf, len, 0);
- if (copy_to_user ((void *) ubuf, info->rxbuf, ret_val) != 0)
+ ret_val = ifx_ssc_read_helper(info, info->rxbuf, len, 0);
+ if (copy_to_user((void *)ubuf, info->rxbuf, ret_val) != 0)
ret_val = -EFAULT;
disable_irq(IFXMIPS_SSC_RIR);
- kfree (info->rxbuf);
+ kfree(info->rxbuf);
info->rxbuf = NULL;
- return (ret_val);
+ return ret_val;
}
-static ssize_t
-ifx_ssc_write (struct file *filp, const char *ubuf, size_t len, loff_t * off)
+static ssize_t ifx_ssc_write(struct file *filp, const char *ubuf, size_t len, loff_t *off)
{
int idx;
struct ifx_ssc_port *info;
int ret_val;
if (len == 0)
- return (0);
+ return 0;
- idx = MINOR (filp->f_dentry->d_inode->i_rdev);
+ idx = MINOR(filp->f_dentry->d_inode->i_rdev);
info = &isp[idx];
if (info->txbuf != NULL)
return -EBUSY;
- info->txbuf = kmalloc (len + 3, GFP_KERNEL);
+ info->txbuf = kmalloc(len + 3, GFP_KERNEL);
if (info->txbuf == NULL)
return -ENOMEM;
- ret_val = copy_from_user (info->txbuf, ubuf, len);
+ ret_val = copy_from_user(info->txbuf, ubuf, len);
if (ret_val == 0)
- ret_val = ifx_ssc_write_helper (info, info->txbuf, len, 0);
+ ret_val = ifx_ssc_write_helper(info, info->txbuf, len, 0);
else
ret_val = -EFAULT;
- if (ret_val < 0)
- {
- kfree (info->txbuf);
+ if (ret_val < 0) {
+ kfree(info->txbuf);
info->txbuf = NULL;
}
- return (ret_val);
+ return ret_val;
}
-static struct ifx_ssc_frm_status *
-ifx_ssc_frm_status_get (struct ifx_ssc_port *info)
+static struct ifx_ssc_frm_status *ifx_ssc_frm_status_get(struct ifx_ssc_port *info)
{
unsigned long tmp;
@@ -655,9 +622,7 @@ ifx_ssc_frm_status_get (struct ifx_ssc_port *info)
return &info->frm_status;
}
-
-static struct ifx_ssc_frm_opts *
-ifx_ssc_frm_control_get (struct ifx_ssc_port *info)
+static struct ifx_ssc_frm_opts *ifx_ssc_frm_control_get(struct ifx_ssc_port *info)
{
unsigned long tmp;
@@ -672,8 +637,7 @@ ifx_ssc_frm_control_get (struct ifx_ssc_port *info)
return &info->frm_opts;
}
-static int
-ifx_ssc_frm_control_set (struct ifx_ssc_port *info)
+static int ifx_ssc_frm_control_set(struct ifx_ssc_port *info)
{
unsigned long tmp;
@@ -685,12 +649,12 @@ ifx_ssc_frm_control_set (struct ifx_ssc_port *info)
|| (info->frm_opts.IdleClock & ~(IFX_SSC_SFCON_PAUSE_CLOCK_MASK >> IFX_SSC_SFCON_PAUSE_CLOCK_OFFSET)))
return -EINVAL;
- // read interrupt bits (they're not changed here)
+ /* read interrupt bits(they're not changed here) */
tmp = ifxmips_r32(IFXMIPS_SSC_SFCON) &
(IFX_SSC_SFCON_FIR_ENABLE_BEFORE_PAUSE | IFX_SSC_SFCON_FIR_ENABLE_AFTER_PAUSE);
- // set all values with respect to it's bit position (for data and pause
- // length set N-1)
+ /* set all values with respect to it's bit position(for data and pause
+ length set N-1) */
tmp = (info->frm_opts.DataLength - 1) << IFX_SSC_SFCON_DATA_LENGTH_OFFSET;
tmp |= (info->frm_opts.PauseLength - 1) << IFX_SSC_SFCON_PAUSE_LENGTH_OFFSET;
tmp |= info->frm_opts.IdleData << IFX_SSC_SFCON_PAUSE_DATA_OFFSET;
@@ -703,8 +667,7 @@ ifx_ssc_frm_control_set (struct ifx_ssc_port *info)
return 0;
}
-static int
-ifx_ssc_rxtx_mode_set (struct ifx_ssc_port *info, unsigned int val)
+static int ifx_ssc_rxtx_mode_set(struct ifx_ssc_port *info, unsigned int val)
{
unsigned long tmp;
@@ -722,8 +685,7 @@ ifx_ssc_rxtx_mode_set (struct ifx_ssc_port *info, unsigned int val)
return 0;
}
-static int
-ifx_ssc_sethwopts (struct ifx_ssc_port *info)
+static int ifx_ssc_sethwopts(struct ifx_ssc_port *info)
{
unsigned long flags, bits;
struct ifx_ssc_hwopts *opts = &info->opts;
@@ -754,8 +716,7 @@ ifx_ssc_sethwopts (struct ifx_ssc_port *info)
if (opts->clockPolarity)
bits |= IFX_SSC_CON_CLOCK_FALL;
- switch (opts->modeRxTx)
- {
+ switch (opts->modeRxTx) {
case IFX_SSC_MODE_TX:
bits |= IFX_SSC_CON_RX_OFF;
break;
@@ -764,27 +725,27 @@ ifx_ssc_sethwopts (struct ifx_ssc_port *info)
break;
}
- local_irq_save (flags);
+ local_irq_save(flags);
ifxmips_w32(bits, IFXMIPS_SSC_CON);
ifxmips_w32((info->opts.gpoCs << IFX_SSC_GPOCON_ISCSB0_POS) |
- (info->opts.gpoInv << IFX_SSC_GPOCON_INVOUT0_POS), IFXMIPS_SSC_GPOCON);
+ (info->opts.gpoInv << IFX_SSC_GPOCON_INVOUT0_POS), IFXMIPS_SSC_GPOCON);
ifxmips_w32(info->opts.gpoCs << IFX_SSC_WHBGPOSTAT_SETOUT0_POS, IFXMIPS_SSC_WHBGPOSTAT);
- //master mode
+ /* master mode */
if (opts->masterSelect)
ifxmips_w32(IFX_SSC_WHBSTATE_SET_MASTER_SELECT, IFXMIPS_SSC_WHBSTATE);
else
ifxmips_w32(IFX_SSC_WHBSTATE_CLR_MASTER_SELECT, IFXMIPS_SSC_WHBSTATE);
- // init serial framing
+ /* init serial framing */
ifxmips_w32(0, IFXMIPS_SSC_SFCON);
/* set up the port pins */
- //check for general requirements to switch (external) pad/pin characteristics
+ /* check for general requirements to switch(external) pad/pin characteristics */
/* TODO: P0.9 SPI_CS4, P0.10 SPI_CS5, P 0.11 SPI_CS6, because of ASC0 */
/* p0.15 SPI_CS1(EEPROM), P0.13 SPI_CS3, */
- /* Set p0.15 to alternative 01, others to 00 (In/OUT) */
+ /* Set p0.15 to alternative 01, others to 00(In/OUT) */
*(IFXMIPS_GPIO_P0_DIR) = (*IFXMIPS_GPIO_P0_DIR) | (0xA000);
*(IFXMIPS_GPIO_P0_ALTSEL0) = (((*IFXMIPS_GPIO_P0_ALTSEL0) | (0x8000)) & (~(0x2000)));
*(IFXMIPS_GPIO_P0_ALTSEL1) = (((*IFXMIPS_GPIO_P0_ALTSEL1) & (~0x8000)) & (~(0x2000)));
@@ -800,13 +761,12 @@ ifx_ssc_sethwopts (struct ifx_ssc_port *info)
/*TODO: CS4 CS5 CS6 */
*IFXMIPS_GPIO_P0_OUT = ((*IFXMIPS_GPIO_P0_OUT) | 0x2000);
- local_irq_restore (flags);
+ local_irq_restore(flags);
return 0;
}
-static int
-ifx_ssc_set_baud (struct ifx_ssc_port *info, unsigned int baud)
+static int ifx_ssc_set_baud(struct ifx_ssc_port *info, unsigned int baud)
{
unsigned int ifx_ssc_clock;
unsigned int br;
@@ -815,13 +775,12 @@ ifx_ssc_set_baud (struct ifx_ssc_port *info, unsigned int baud)
int retval = 0;
ifx_ssc_clock = ifx_ssc_get_kernel_clk(info);
- if (ifx_ssc_clock == 0)
- {
+ if (ifx_ssc_clock == 0) {
retval = -EINVAL;
goto out;
}
- local_irq_save (flags);
+ local_irq_save(flags);
enabled = (ifxmips_r32(IFXMIPS_SSC_STATE) & IFX_SSC_STATE_IS_ENABLED);
ifxmips_w32(IFX_SSC_WHBSTATE_CLR_ENABLE, IFXMIPS_SSC_WHBSTATE);
@@ -831,8 +790,8 @@ ifx_ssc_set_baud (struct ifx_ssc_port *info, unsigned int baud)
if (br > 0xffff || ((br == 0) &&
((ifxmips_r32(IFXMIPS_SSC_STATE) & IFX_SSC_STATE_IS_MASTER) == 0))) {
- local_irq_restore (flags);
- printk ("%s: invalid baudrate %u\n", __func__, baud);
+ local_irq_restore(flags);
+ printk("%s: invalid baudrate %u\n", __func__, baud);
return -EINVAL;
}
@@ -847,8 +806,7 @@ out:
return retval;
}
-static int
-ifx_ssc_hwinit (struct ifx_ssc_port *info)
+static int ifx_ssc_hwinit(struct ifx_ssc_port *info)
{
unsigned long flags;
bool enabled;
@@ -856,26 +814,24 @@ ifx_ssc_hwinit (struct ifx_ssc_port *info)
enabled = (ifxmips_r32(IFXMIPS_SSC_STATE) & IFX_SSC_STATE_IS_ENABLED);
ifxmips_w32(IFX_SSC_WHBSTATE_CLR_ENABLE, IFXMIPS_SSC_WHBSTATE);
- if (ifx_ssc_sethwopts (info) < 0)
- {
- printk ("%s: setting the hardware options failed\n", __func__);
+ if (ifx_ssc_sethwopts(info) < 0) {
+ printk("%s: setting the hardware options failed\n", __func__);
return -EINVAL;
}
- if (ifx_ssc_set_baud (info, info->baud) < 0)
- {
- printk ("%s: setting the baud rate failed\n", __func__);
+ if (ifx_ssc_set_baud(info, info->baud) < 0) {
+ printk("%s: setting the baud rate failed\n", __func__);
return -EINVAL;
}
- local_irq_save (flags);
+ local_irq_save(flags);
/* TX FIFO */
ifxmips_w32((IFX_SSC_DEF_TXFIFO_FL << IFX_SSC_XFCON_ITL_OFFSET) | IFX_SSC_XFCON_FIFO_ENABLE, IFXMIPS_SSC_TXFCON);
/* RX FIFO */
ifxmips_w32((IFX_SSC_DEF_RXFIFO_FL << IFX_SSC_XFCON_ITL_OFFSET) | IFX_SSC_XFCON_FIFO_ENABLE, IFXMIPS_SSC_RXFCON);
- local_irq_restore (flags);
+ local_irq_restore(flags);
if (enabled)
ifxmips_w32(IFX_SSC_WHBSTATE_SET_ENABLE, IFXMIPS_SSC_WHBSTATE);
@@ -883,8 +839,8 @@ ifx_ssc_hwinit (struct ifx_ssc_port *info)
return 0;
}
-int
-ifx_ssc_ioctl (struct inode *inode, struct file *filp, unsigned int cmd, unsigned long data)
+int ifx_ssc_ioctl(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long data)
{
struct ifx_ssc_port *info;
int line, ret_val = 0;
@@ -892,49 +848,46 @@ ifx_ssc_ioctl (struct inode *inode, struct file *filp, unsigned int cmd, unsigne
unsigned long tmp;
int from_kernel = 0;
- if ((inode == (struct inode *) 0) || (inode == (struct inode *) 1))
- {
+ if ((inode == (struct inode *)0) || (inode == (struct inode *)1)) {
from_kernel = 1;
line = (int) inode;
- } else {
- line = MINOR (filp->f_dentry->d_inode->i_rdev);
- }
+ } else
+ line = MINOR(filp->f_dentry->d_inode->i_rdev);
if (line < 0 || line >= PORT_CNT)
return -ENXIO;
info = &isp[line];
- switch (cmd)
- {
+ switch (cmd) {
case IFX_SSC_STATS_READ:
/* data must be a pointer to a struct ifx_ssc_statistics */
if (from_kernel)
- memcpy ((void *) data, (void *) &info->stats,
- sizeof (struct ifx_ssc_statistics));
- else if (copy_to_user ((void *) data,
- (void *) &info->stats,
- sizeof (struct ifx_ssc_statistics)))
+ memcpy((void *)data, (void *)&info->stats,
+ sizeof(struct ifx_ssc_statistics));
+ else if (copy_to_user((void *)data,
+ (void *)&info->stats,
+ sizeof(struct ifx_ssc_statistics)))
ret_val = -EFAULT;
break;
case IFX_SSC_STATS_RESET:
/* just resets the statistics counters */
- memset ((void *) &info->stats, 0,
- sizeof (struct ifx_ssc_statistics));
+ memset((void *)&info->stats, 0,
+ sizeof(struct ifx_ssc_statistics));
break;
case IFX_SSC_BAUD_SET:
/* if the buffers are not empty then the port is */
/* busy and we shouldn't change things on-the-fly! */
if (!info->txbuf || !info->rxbuf ||
- (ifxmips_r32(IFXMIPS_SSC_STATE) & IFX_SSC_STATE_BUSY)) {
+ (ifxmips_r32(IFXMIPS_SSC_STATE) & IFX_SSC_STATE_BUSY)) {
ret_val = -EBUSY;
break;
}
/* misuse flags */
if (from_kernel)
- flags = *((unsigned long *) data);
- else if (copy_from_user ((void *) &flags,
- (void *) data, sizeof (flags))) {
+ flags = *((unsigned long *)data);
+ else if (copy_from_user((void *)&flags,
+ (void *)data, sizeof(flags))) {
ret_val = -EFAULT;
break;
}
@@ -942,7 +895,7 @@ ifx_ssc_ioctl (struct inode *inode, struct file *filp, unsigned int cmd, unsigne
ret_val = -EINVAL;
break;
}
- if (ifx_ssc_set_baud (info, flags) < 0) {
+ if (ifx_ssc_set_baud(info, flags) < 0) {
ret_val = -EINVAL;
break;
}
@@ -950,41 +903,41 @@ ifx_ssc_ioctl (struct inode *inode, struct file *filp, unsigned int cmd, unsigne
break;
case IFX_SSC_BAUD_GET:
if (from_kernel)
- *((unsigned int *) data) = info->baud;
- else if (copy_to_user ((void *) data,
- (void *) &info->baud,
- sizeof (unsigned long)))
+ *((unsigned int *)data) = info->baud;
+ else if (copy_to_user((void *)data,
+ (void *)&info->baud,
+ sizeof(unsigned long)))
ret_val = -EFAULT;
break;
case IFX_SSC_RXTX_MODE_SET:
if (from_kernel)
- tmp = *((unsigned long *) data);
- else if (copy_from_user ((void *) &tmp,
- (void *) data, sizeof (tmp))) {
+ tmp = *((unsigned long *)data);
+ else if (copy_from_user((void *)&tmp,
+ (void *)data, sizeof(tmp))) {
ret_val = -EFAULT;
break;
}
- ret_val = ifx_ssc_rxtx_mode_set (info, tmp);
+ ret_val = ifx_ssc_rxtx_mode_set(info, tmp);
break;
case IFX_SSC_RXTX_MODE_GET:
tmp = ifxmips_r32(IFXMIPS_SSC_CON) &
(~(IFX_SSC_CON_RX_OFF | IFX_SSC_CON_TX_OFF));
if (from_kernel)
- *((unsigned int *) data) = tmp;
- else if (copy_to_user ((void *) data,
- (void *) &tmp, sizeof (tmp)))
+ *((unsigned int *)data) = tmp;
+ else if (copy_to_user((void *)data,
+ (void *)&tmp, sizeof(tmp)))
ret_val = -EFAULT;
break;
case IFX_SSC_ABORT:
- ifx_ssc_abort (info);
+ ifx_ssc_abort(info);
break;
case IFX_SSC_GPO_OUT_SET:
if (from_kernel)
- tmp = *((unsigned long *) data);
- else if (copy_from_user ((void *) &tmp,
- (void *) data, sizeof (tmp))) {
+ tmp = *((unsigned long *)data);
+ else if (copy_from_user((void *)&tmp,
+ (void *)data, sizeof(tmp))) {
ret_val = -EFAULT;
break;
}
@@ -996,88 +949,86 @@ ifx_ssc_ioctl (struct inode *inode, struct file *filp, unsigned int cmd, unsigne
break;
case IFX_SSC_GPO_OUT_CLR:
if (from_kernel)
- tmp = *((unsigned long *) data);
- else if (copy_from_user ((void *) &tmp, (void *) data, sizeof (tmp))) {
+ tmp = *((unsigned long *)data);
+ else if (copy_from_user((void *)&tmp, (void *)data, sizeof(tmp))) {
ret_val = -EFAULT;
break;
}
if (tmp > IFX_SSC_MAX_GPO_OUT)
ret_val = -EINVAL;
- else {
+ else
ifxmips_w32(1 << (tmp + IFX_SSC_WHBGPOSTAT_CLROUT0_POS),
IFXMIPS_SSC_WHBGPOSTAT);
- }
break;
case IFX_SSC_GPO_OUT_GET:
tmp = ifxmips_r32(IFXMIPS_SSC_GPOSTAT);
if (from_kernel)
- *((unsigned int *) data) = tmp;
- else if (copy_to_user ((void *) data,
- (void *) &tmp, sizeof (tmp)))
+ *((unsigned int *)data) = tmp;
+ else if (copy_to_user((void *)data,
+ (void *)&tmp, sizeof(tmp)))
ret_val = -EFAULT;
break;
case IFX_SSC_FRM_STATUS_GET:
- ifx_ssc_frm_status_get (info);
+ ifx_ssc_frm_status_get(info);
if (from_kernel)
- memcpy ((void *) data, (void *) &info->frm_status,
- sizeof (struct ifx_ssc_frm_status));
- else if (copy_to_user ((void *) data,
- (void *) &info->frm_status,
- sizeof (struct ifx_ssc_frm_status)))
+ memcpy((void *)data, (void *)&info->frm_status,
+ sizeof(struct ifx_ssc_frm_status));
+ else if (copy_to_user((void *)data,
+ (void *)&info->frm_status,
+ sizeof(struct ifx_ssc_frm_status)))
ret_val = -EFAULT;
break;
case IFX_SSC_FRM_CONTROL_GET:
- ifx_ssc_frm_control_get (info);
+ ifx_ssc_frm_control_get(info);
if (from_kernel)
- memcpy ((void *) data, (void *) &info->frm_opts,
- sizeof (struct ifx_ssc_frm_opts));
- else if (copy_to_user ((void *) data,
- (void *) &info->frm_opts,
- sizeof (struct ifx_ssc_frm_opts)))
+ memcpy((void *)data, (void *)&info->frm_opts,
+ sizeof(struct ifx_ssc_frm_opts));
+ else if (copy_to_user((void *)data,
+ (void *)&info->frm_opts,
+ sizeof(struct ifx_ssc_frm_opts)))
ret_val = -EFAULT;
break;
case IFX_SSC_FRM_CONTROL_SET:
if (from_kernel)
- memcpy ((void *) &info->frm_opts, (void *) data,
- sizeof (struct ifx_ssc_frm_opts));
- else if (copy_to_user ((void *) &info->frm_opts,
- (void *) data,
- sizeof (struct ifx_ssc_frm_opts))) {
+ memcpy((void *)&info->frm_opts, (void *)data,
+ sizeof(struct ifx_ssc_frm_opts));
+ else if (copy_to_user((void *)&info->frm_opts,
+ (void *)data,
+ sizeof(struct ifx_ssc_frm_opts))) {
ret_val = -EFAULT;
break;
}
- ret_val = ifx_ssc_frm_control_set (info);
+ ret_val = ifx_ssc_frm_control_set(info);
break;
case IFX_SSC_HWOPTS_SET:
/* data must be a pointer to a struct ifx_ssc_hwopts */
/* if the buffers are not empty then the port is */
/* busy and we shouldn't change things on-the-fly! */
if (!info->txbuf || !info->rxbuf ||
- (ifxmips_r32(IFXMIPS_SSC_STATE)
+ (ifxmips_r32(IFXMIPS_SSC_STATE)
& IFX_SSC_STATE_BUSY)) {
ret_val = -EBUSY;
break;
}
if (from_kernel)
- memcpy ((void *) &info->opts, (void *) data,
- sizeof (struct ifx_ssc_hwopts));
- else if (copy_from_user ((void *) &info->opts,
- (void *) data, sizeof(struct ifx_ssc_hwopts))) {
+ memcpy((void *)&info->opts, (void *)data,
+ sizeof(struct ifx_ssc_hwopts));
+ else if (copy_from_user((void *)&info->opts,
+ (void *)data, sizeof(struct ifx_ssc_hwopts))) {
ret_val = -EFAULT;
break;
}
- if (ifx_ssc_hwinit (info) < 0) {
+ if (ifx_ssc_hwinit(info) < 0)
ret_val = -EIO;
- }
break;
case IFX_SSC_HWOPTS_GET:
/* data must be a pointer to a struct ifx_ssc_hwopts */
if (from_kernel)
- memcpy ((void *) data, (void *) &info->opts,
- sizeof (struct ifx_ssc_hwopts));
- else if (copy_to_user ((void *) data,
- (void *) &info->opts,
- sizeof (struct ifx_ssc_hwopts)))
+ memcpy((void *)data, (void *)&info->opts,
+ sizeof(struct ifx_ssc_hwopts));
+ else if (copy_to_user((void *)data,
+ (void *)&info->opts,
+ sizeof(struct ifx_ssc_hwopts)))
ret_val = -EFAULT;
break;
default:
@@ -1089,16 +1040,15 @@ ifx_ssc_ioctl (struct inode *inode, struct file *filp, unsigned int cmd, unsigne
EXPORT_SYMBOL(ifx_ssc_ioctl);
static struct file_operations ifx_ssc_fops = {
- .owner = THIS_MODULE,
- .read = ifx_ssc_read,
- .write = ifx_ssc_write,
- .ioctl = ifx_ssc_ioctl,
- .open = ifx_ssc_open,
- .release = ifx_ssc_close,
+ .owner = THIS_MODULE,
+ .read = ifx_ssc_read,
+ .write = ifx_ssc_write,
+ .ioctl = ifx_ssc_ioctl,
+ .open = ifx_ssc_open,
+ .release = ifx_ssc_close,
};
-int __init
-ifx_ssc_init (void)
+int __init ifx_ssc_init(void)
{
struct ifx_ssc_port *info;
int i, nbytes;
@@ -1107,27 +1057,25 @@ ifx_ssc_init (void)
ret_val = -ENOMEM;
nbytes = PORT_CNT * sizeof(struct ifx_ssc_port);
- isp = (struct ifx_ssc_port*)kmalloc(nbytes, GFP_KERNEL);
+ isp = kmalloc(nbytes, GFP_KERNEL);
- if (isp == NULL)
- {
+ if (isp == NULL) {
printk("%s: no memory for isp\n", __func__);
- return (ret_val);
+ return ret_val;
}
memset(isp, 0, nbytes);
ret_val = -ENXIO;
- if ((i = register_chrdev (maj, "ssc", &ifx_ssc_fops)) < 0)
- {
- printk ("Unable to register major %d for the Infineon SSC\n", maj);
- if (maj == 0)
- {
+ i = register_chrdev(maj, "ssc", &ifx_ssc_fops);
+ if (i < 0) {
+ printk("Unable to register major %d for the Infineon SSC\n", maj);
+ if (maj == 0) {
goto errout;
} else {
maj = 0;
- if ((i = register_chrdev (maj, "ssc", &ifx_ssc_fops)) < 0)
- {
- printk ("Unable to register major %d for the Infineon SSC\n", maj);
+ i = register_chrdev(maj, "ssc", &ifx_ssc_fops);
+ if (i < 0) {
+ printk("Unable to register major %d for the Infineon SSC\n", maj);
goto errout;
}
}
@@ -1161,56 +1109,53 @@ ifx_ssc_init (void)
info->rxbuf = NULL;
info->txbuf = NULL;
/* values specific to SSC1 */
- if (i == 0) {
+ if (i == 0)
info->mapbase = IFXMIPS_SSC_BASE_ADDR;
- }
ifxmips_w32(IFX_SSC_DEF_RMC << IFX_CLC_RUN_DIVIDER_OFFSET, IFXMIPS_SSC_CLC);
- init_waitqueue_head (&info->rwait);
+ init_waitqueue_head(&info->rwait);
- local_irq_save (flags);
+ local_irq_save(flags);
- // init serial framing register
+ /* init serial framing register */
ifxmips_w32(IFX_SSC_DEF_SFCON, IFXMIPS_SSC_SFCON);
ret_val = request_irq(IFXMIPS_SSC_TIR, ifx_ssc_tx_int, IRQF_DISABLED, "ifx_ssc_tx", info);
- if (ret_val)
- {
+ if (ret_val) {
printk("%s: unable to get irq %d\n", __func__, IFXMIPS_SSC_TIR);
local_irq_restore(flags);
goto errout;
}
ret_val = request_irq(IFXMIPS_SSC_RIR, ifx_ssc_rx_int, IRQF_DISABLED, "ifx_ssc_rx", info);
- if (ret_val)
- {
- printk ("%s: unable to get irq %d\n", __func__, IFXMIPS_SSC_RIR);
- local_irq_restore (flags);
+ if (ret_val) {
+ printk("%s: unable to get irq %d\n", __func__, IFXMIPS_SSC_RIR);
+ local_irq_restore(flags);
goto irqerr;
}
ret_val = request_irq(IFXMIPS_SSC_EIR, ifx_ssc_err_int, IRQF_DISABLED, "ifx_ssc_err", info);
- if (ret_val)
- {
- printk ("%s: unable to get irq %d\n", __func__, IFXMIPS_SSC_EIR);
- local_irq_restore (flags);
+ if (ret_val) {
+ printk("%s: unable to get irq %d\n", __func__, IFXMIPS_SSC_EIR);
+ local_irq_restore(flags);
goto irqerr;
}
ifxmips_w32(IFX_SSC_DEF_IRNEN, IFXMIPS_SSC_IRN);
- //enable_irq(IFXMIPS_SSC_TIR);
- //enable_irq(IFXMIPS_SSC_RIR);
- //enable_irq(IFXMIPS_SSC_EIR);
+ #if 0
+ enable_irq(IFXMIPS_SSC_TIR);
+ enable_irq(IFXMIPS_SSC_RIR);
+ enable_irq(IFXMIPS_SSC_EIR);
+ #endif
- local_irq_restore (flags);
+ local_irq_restore(flags);
}
for (i = 0; i < PORT_CNT; i++) {
info = &isp[i];
- if (ifx_ssc_hwinit (info) < 0)
- {
- printk ("%s: hardware init failed for port %d\n", __func__, i);
+ if (ifx_ssc_hwinit(info) < 0) {
+ printk("%s: hardware init failed for port %d\n", __func__, i);
goto irqerr;
}
}
@@ -1223,12 +1168,11 @@ irqerr:
free_irq(IFXMIPS_SSC_RIR, &isp[0]);
free_irq(IFXMIPS_SSC_EIR, &isp[0]);
errout:
- kfree (isp);
- return (ret_val);
+ kfree(isp);
+ return ret_val;
}
-void
-ifx_ssc_cleanup_module (void)
+void __exit ifx_ssc_cleanup_module(void)
{
int i;
@@ -1238,39 +1182,37 @@ ifx_ssc_cleanup_module (void)
free_irq(IFXMIPS_SSC_RIR, &isp[i]);
free_irq(IFXMIPS_SSC_EIR, &isp[i]);
}
- kfree (isp);
+ kfree(isp);
}
module_init(ifx_ssc_init);
module_exit(ifx_ssc_cleanup_module);
-
-inline int
-ifx_ssc_cs_low (u32 pin)
+inline int ifx_ssc_cs_low(u32 pin)
{
int ret = 0;
- if ((ret = ifx_ssc_ioctl ((struct inode *) 0, NULL, IFX_SSC_GPO_OUT_CLR, (unsigned long) &pin)))
- printk ("clear CS %d fails\n", pin);
- wmb ();
+ ret = ifx_ssc_ioctl((struct inode *)0, NULL, IFX_SSC_GPO_OUT_CLR, (unsigned long) &pin);
+ if (ret)
+ printk("clear CS %d fails\n", pin);
+ wmb();
return ret;
}
EXPORT_SYMBOL(ifx_ssc_cs_low);
-inline int
-ifx_ssc_cs_high (u32 pin)
+inline int ifx_ssc_cs_high(u32 pin)
{
int ret = 0;
- if ((ret = ifx_ssc_ioctl((struct inode *) 0, NULL, IFX_SSC_GPO_OUT_SET, (unsigned long) &pin)))
- printk ("set CS %d fails\n", pin);
- wmb ();
+ ret = ifx_ssc_ioctl((struct inode *)0, NULL, IFX_SSC_GPO_OUT_SET, (unsigned long) &pin);
+ if (ret)
+ printk("set CS %d fails\n", pin);
+ wmb();
return ret;
}
EXPORT_SYMBOL(ifx_ssc_cs_high);
-static int
-ssc_session (char *tx_buf, u32 tx_len, char *rx_buf, u32 rx_len)
+static int ssc_session(char *tx_buf, u32 tx_len, char *rx_buf, u32 rx_len)
{
int ret = 0;
@@ -1280,132 +1222,111 @@ ssc_session (char *tx_buf, u32 tx_len, char *rx_buf, u32 rx_len)
u8 mode = 0;
if (tx_buf == NULL && tx_len == 0 && rx_buf == NULL && rx_len == 0) {
- printk ("invalid parameters\n");
+ printk("invalid parameters\n");
ret = -EINVAL;
goto ssc_session_exit;
- }
- else if (tx_buf == NULL || tx_len == 0) {
+ } else if (tx_buf == NULL || tx_len == 0) {
if (rx_buf != NULL && rx_len != 0) {
mode = IFX_SSC_MODE_RX;
- }
- else {
- printk ("invalid parameters\n");
+ } else {
+ printk("invalid parameters\n");
ret = -EINVAL;
goto ssc_session_exit;
}
- }
- else if (rx_buf == NULL || rx_len == 0) {
- if (tx_buf != NULL && tx_len != 0) {
+ } else if (rx_buf == NULL || rx_len == 0) {
+ if (tx_buf != NULL && tx_len != 0)
mode = IFX_SSC_MODE_TX;
- }
else {
- printk ("invalid parameters\n");
+ printk("invalid parameters\n");
ret = -EINVAL;
goto ssc_session_exit;
}
- }
- else {
+ } else
mode = IFX_SSC_MODE_RXTX;
- }
- if (mode == IFX_SSC_MODE_RXTX) {
+ if (mode == IFX_SSC_MODE_RXTX)
eff_size = tx_len + rx_len;
- }
- else if (mode == IFX_SSC_MODE_RX) {
+ else if (mode == IFX_SSC_MODE_RX)
eff_size = rx_len;
- }
- else {
+ else
eff_size = tx_len;
- }
//4 bytes alignment, required by driver
/* change by TaiCheng */
//if (in_irq()){
if (1) {
- ssc_tx_buf =
- (char *) kmalloc (sizeof (char) *
- ((eff_size + 3) & (~3)),
+ ssc_tx_buf = kmalloc(sizeof(char) *
+ ((eff_size + 3) & (~3)),
GFP_ATOMIC);
- ssc_rx_buf =
- (char *) kmalloc (sizeof (char) *
- ((eff_size + 3) & (~3)),
+ ssc_rx_buf = kmalloc(sizeof(char) *
+ ((eff_size + 3) & (~3)),
GFP_ATOMIC);
- }
- else {
- ssc_tx_buf =
- (char *) kmalloc (sizeof (char) *
- ((eff_size + 3) & (~3)),
+ } else {
+ ssc_tx_buf = kmalloc(sizeof(char) *
+ ((eff_size + 3) & (~3)),
GFP_KERNEL);
- ssc_rx_buf =
- (char *) kmalloc (sizeof (char) *
- ((eff_size + 3) & (~3)),
+ ssc_rx_buf = kmalloc(sizeof(char) *
+ ((eff_size + 3) & (~3)),
GFP_KERNEL);
}
if (ssc_tx_buf == NULL || ssc_rx_buf == NULL) {
- printk ("no memory for size of %d\n", eff_size);
+ printk("no memory for size of %d\n", eff_size);
ret = -ENOMEM;
goto ssc_session_exit;
}
- memset ((void *) ssc_tx_buf, 0, eff_size);
- memset ((void *) ssc_rx_buf, 0, eff_size);
+ memset((void *)ssc_tx_buf, 0, eff_size);
+ memset((void *)ssc_rx_buf, 0, eff_size);
- if (tx_len > 0) {
- memcpy (ssc_tx_buf, tx_buf, tx_len);
- }
+ if (tx_len > 0)
+ memcpy(ssc_tx_buf, tx_buf, tx_len);
- ret = ifx_ssc_kwrite (0, ssc_tx_buf, eff_size);
+ ret = ifx_ssc_kwrite(0, ssc_tx_buf, eff_size);
- if (ret > 0) {
- ssc_tx_buf = NULL; //should be freed by ifx_ssc_kwrite
- }
+ if (ret > 0)
+ ssc_tx_buf = NULL; /* should be freed by ifx_ssc_kwrite */
if (ret != eff_size) {
- printk ("ifx_ssc_write return %d\n", ret);
+ printk("ifx_ssc_write return %d\n", ret);
goto ssc_session_exit;
}
- ret = ifx_ssc_kread (0, ssc_rx_buf, eff_size);
+ ret = ifx_ssc_kread(0, ssc_rx_buf, eff_size);
if (ret != eff_size) {
- printk ("ifx_ssc_read return %d\n", ret);
+ printk("ifx_ssc_read return %d\n", ret);
goto ssc_session_exit;
}
- memcpy (rx_buf, ssc_rx_buf + tx_len, rx_len);
+ memcpy(rx_buf, ssc_rx_buf + tx_len, rx_len);
- if (mode == IFX_SSC_MODE_TX) {
+ if (mode == IFX_SSC_MODE_TX)
ret = tx_len;
- }
- else {
+ else
ret = rx_len;
- }
- ssc_session_exit:
+ssc_session_exit:
if (ssc_tx_buf != NULL)
- kfree (ssc_tx_buf);
+ kfree(ssc_tx_buf);
if (ssc_rx_buf != NULL)
- kfree (ssc_rx_buf);
+ kfree(ssc_rx_buf);
+
+ if (ret < 0)
+ printk("ssc session fails\n");
- if (ret < 0) {
- printk ("ssc session fails\n");
- }
return ret;
}
-int
-ifx_ssc_txrx (char *tx_buf, u32 tx_len, char *rx_buf, u32 rx_len)
+int ifx_ssc_txrx(char *tx_buf, u32 tx_len, char *rx_buf, u32 rx_len)
{
return ssc_session(tx_buf, tx_len, rx_buf, rx_len);
}
EXPORT_SYMBOL(ifx_ssc_txrx);
-int
-ifx_ssc_tx (char *tx_buf, u32 tx_len)
+int ifx_ssc_tx(char *tx_buf, u32 tx_len)
{
return ssc_session(tx_buf, tx_len, NULL, 0);
}
EXPORT_SYMBOL(ifx_ssc_tx);
-int
-ifx_ssc_rx (char *rx_buf, u32 rx_len)
+int ifx_ssc_rx(char *rx_buf, u32 rx_len)
{
return ssc_session(NULL, 0, rx_buf, rx_len);
}
diff --git a/target/linux/ifxmips/files/drivers/leds/leds-ifxmips.c b/target/linux/ifxmips/files/drivers/leds/leds-ifxmips.c
index 090516c5a..7efc03270 100644
--- a/target/linux/ifxmips/files/drivers/leds/leds-ifxmips.c
+++ b/target/linux/ifxmips/files/drivers/leds/leds-ifxmips.c
@@ -25,65 +25,61 @@
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/platform_device.h>
-#include <asm/uaccess.h>
-#include <asm/unistd.h>
+#include <linux/uaccess.h>
+#include <linux/unistd.h>
#include <linux/errno.h>
+#include <linux/leds.h>
+#include <linux/delay.h>
+
#include <asm/ifxmips/ifxmips.h>
#include <asm/ifxmips/ifxmips_gpio.h>
#include <asm/ifxmips/ifxmips_pmu.h>
-#include <linux/leds.h>
-#include <linux/delay.h>
-#define DRVNAME "ifxmips_led"
+#define DRVNAME "ifxmips_led"
#define IFXMIPS_LED_CLK_EDGE IFXMIPS_LED_FALLING
//#define IFXMIPS_LED_CLK_EDGE IFXMIPS_LED_RISING
-#define IFXMIPS_LED_SPEED IFXMIPS_LED_8HZ
+#define IFXMIPS_LED_SPEED IFXMIPS_LED_8HZ
#define IFXMIPS_LED_GPIO_PORT 0
-#define IFXMIPS_MAX_LED 24
+#define IFXMIPS_MAX_LED 24
struct ifxmips_led {
struct led_classdev cdev;
u8 bit;
};
-void
-ifxmips_led_set (unsigned int led)
+void ifxmips_led_set (unsigned int led)
{
led &= 0xffffff;
ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CPU0) | led, IFXMIPS_LED_CPU0);
}
EXPORT_SYMBOL(ifxmips_led_set);
-void
-ifxmips_led_clear (unsigned int led)
+void ifxmips_led_clear (unsigned int led)
{
led = ~(led & 0xffffff);
ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CPU0) & led, IFXMIPS_LED_CPU0);
}
EXPORT_SYMBOL(ifxmips_led_clear);
-void
-ifxmips_led_blink_set (unsigned int led)
+void ifxmips_led_blink_set (unsigned int led)
{
led &= 0xffffff;
ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) | led, IFXMIPS_LED_CON0);
}
EXPORT_SYMBOL(ifxmips_led_blink_set);
-void
-ifxmips_led_blink_clear (unsigned int led)
+void ifxmips_led_blink_clear (unsigned int led)
{
led = ~(led & 0xffffff);
ifxmips_w32(ifxmips_r32(IFXMIPS_LED_CON0) & led, IFXMIPS_LED_CON0);
}
EXPORT_SYMBOL(ifxmips_led_blink_clear);
-void
-ifxmips_ledapi_set(struct led_classdev *led_cdev, enum led_brightness value)
+void ifxmips_ledapi_set(struct led_classdev *led_cdev, enum led_brightness value)
{
struct ifxmips_led *led_dev = container_of(led_cdev, struct ifxmips_led, cdev);
@@ -93,14 +89,12 @@ ifxmips_ledapi_set(struct led_classdev *led_cdev, enum led_brightness value)
ifxmips_led_clear(1 << led_dev->bit);
}
-void
-ifxmips_led_setup_gpio (void)
+void ifxmips_led_setup_gpio (void)
{
int i = 0;
/* we need to setup pins SH,D,ST (4,5,6) */
- for (i = 4; i < 7; i++)
- {
+ for (i = 4; i < 7; i++) {
ifxmips_port_set_altsel0(IFXMIPS_LED_GPIO_PORT, i);
ifxmips_port_clear_altsel1(IFXMIPS_LED_GPIO_PORT, i);
ifxmips_port_set_dir_out(IFXMIPS_LED_GPIO_PORT, i);
@@ -108,8 +102,7 @@ ifxmips_led_setup_gpio (void)
}
}
-static int
-ifxmips_led_probe(struct platform_device *dev)
+static int ifxmips_led_probe(struct platform_device *dev)
{
int i = 0;
@@ -142,12 +135,11 @@ ifxmips_led_probe(struct platform_device *dev)
/* per default, the leds are turned on */
ifxmips_pmu_enable(IFXMIPS_PMU_PWDCR_LED);
- for(i = 0; i < IFXMIPS_MAX_LED; i++)
- {
+ for (i = 0; i < IFXMIPS_MAX_LED; i++) {
struct ifxmips_led *tmp = kzalloc(sizeof(struct ifxmips_led), GFP_KERNEL);
tmp->cdev.brightness_set = ifxmips_ledapi_set;
tmp->cdev.name = kmalloc(sizeof("ifxmips:led:00"), GFP_KERNEL);
- sprintf((char*)tmp->cdev.name, "ifxmips:led:%02d", i);
+ sprintf((char *)tmp->cdev.name, "ifxmips:led:%02d", i);
tmp->cdev.default_trigger = NULL;
tmp->bit = i;
led_classdev_register(&dev->dev, &tmp->cdev);
@@ -156,14 +148,12 @@ ifxmips_led_probe(struct platform_device *dev)
return 0;
}
-static int
-ifxmips_led_remove(struct platform_device *pdev)
+static int ifxmips_led_remove(struct platform_device *pdev)
{
return 0;
}
-static struct
-platform_driver ifxmips_led_driver = {
+static struct platform_driver ifxmips_led_driver = {
.probe = ifxmips_led_probe,
.remove = ifxmips_led_remove,
.driver = {
@@ -172,8 +162,7 @@ platform_driver ifxmips_led_driver = {
},
};
-int __init
-ifxmips_led_init (void)
+int __init ifxmips_led_init (void)
{
int ret = platform_driver_register(&ifxmips_led_driver);
if (ret)
@@ -182,8 +171,7 @@ ifxmips_led_init (void)
return ret;
}
-void __exit
-ifxmips_led_exit (void)
+void __exit ifxmips_led_exit (void)
{
platform_driver_unregister(&ifxmips_led_driver);
}
diff --git a/target/linux/ifxmips/files/drivers/mtd/maps/ifxmips.c b/target/linux/ifxmips/files/drivers/mtd/maps/ifxmips.c
index aed241b98..b4faf0535 100644
--- a/target/linux/ifxmips/files/drivers/mtd/maps/ifxmips.c
+++ b/target/linux/ifxmips/files/drivers/mtd/maps/ifxmips.c
@@ -26,11 +26,12 @@
#include <linux/mtd/map.h>
#include <linux/mtd/partitions.h>
#include <linux/mtd/cfi.h>
+#include <linux/magic.h>
+#include <linux/platform_device.h>
+
#include <asm/ifxmips/ifxmips.h>
#include <asm/ifxmips/ifxmips_prom.h>
#include <asm/ifxmips/ifxmips_ebu.h>
-#include <linux/magic.h>
-#include <linux/platform_device.h>
#ifndef CONFIG_MTD_PARTITIONS
#error Please enable CONFIG_MTD_PARTITIONS
diff --git a/target/linux/ifxmips/files/drivers/net/ifxmips_mii0.c b/target/linux/ifxmips/files/drivers/net/ifxmips_mii0.c
index fafb5a52f..695e0b77a 100644
--- a/target/linux/ifxmips/files/drivers/net/ifxmips_mii0.c
+++ b/target/linux/ifxmips/files/drivers/net/ifxmips_mii0.c
@@ -48,43 +48,39 @@ struct ifxmips_mii_priv {
static struct net_device *ifxmips_mii0_dev;
static unsigned char mac_addr[MAX_ADDR_LEN];
-void
-ifxmips_write_mdio(u32 phy_addr, u32 phy_reg, u16 phy_data)
+void ifxmips_write_mdio(u32 phy_addr, u32 phy_reg, u16 phy_data)
{
u32 val = MDIO_ACC_REQUEST |
((phy_addr & MDIO_ACC_ADDR_MASK) << MDIO_ACC_ADDR_OFFSET) |
((phy_reg & MDIO_ACC_REG_MASK) << MDIO_ACC_REG_OFFSET) |
phy_data;
- while(ifxmips_r32(IFXMIPS_PPE32_MDIO_ACC) & MDIO_ACC_REQUEST);
+ while (ifxmips_r32(IFXMIPS_PPE32_MDIO_ACC) & MDIO_ACC_REQUEST);
ifxmips_w32(val, IFXMIPS_PPE32_MDIO_ACC);
}
EXPORT_SYMBOL(ifxmips_write_mdio);
-unsigned short
-ifxmips_read_mdio(u32 phy_addr, u32 phy_reg)
+unsigned short ifxmips_read_mdio(u32 phy_addr, u32 phy_reg)
{
u32 val = MDIO_ACC_REQUEST | MDIO_ACC_READ |
((phy_addr & MDIO_ACC_ADDR_MASK) << MDIO_ACC_ADDR_OFFSET) |
((phy_reg & MDIO_ACC_REG_MASK) << MDIO_ACC_REG_OFFSET);
- while(ifxmips_r32(IFXMIPS_PPE32_MDIO_ACC) & MDIO_ACC_REQUEST);
+ while (ifxmips_r32(IFXMIPS_PPE32_MDIO_ACC) & MDIO_ACC_REQUEST) ;
ifxmips_w32(val, IFXMIPS_PPE32_MDIO_ACC);
- while(ifxmips_r32(IFXMIPS_PPE32_MDIO_ACC) & MDIO_ACC_REQUEST){};
+ while (ifxmips_r32(IFXMIPS_PPE32_MDIO_ACC) & MDIO_ACC_REQUEST) ;
val = ifxmips_r32(IFXMIPS_PPE32_MDIO_ACC) & MDIO_ACC_VAL_MASK;
return val;
}
EXPORT_SYMBOL(ifxmips_read_mdio);
-int
-ifxmips_ifxmips_mii_open(struct net_device *dev)
+int ifxmips_ifxmips_mii_open(struct net_device *dev)
{
- struct ifxmips_mii_priv* priv = (struct ifxmips_mii_priv*)dev->priv;
- struct dma_device_info* dma_dev = priv->dma_device;
+ struct ifxmips_mii_priv *priv = (struct ifxmips_mii_priv *)dev->priv;
+ struct dma_device_info *dma_dev = priv->dma_device;
int i;
- for (i = 0; i < dma_dev->max_rx_chan_num; i++)
- {
+ for (i = 0; i < dma_dev->max_rx_chan_num; i++) {
if ((dma_dev->rx_chan[i])->control == IFXMIPS_DMA_CH_ON)
(dma_dev->rx_chan[i])->open(dma_dev->rx_chan[i]);
}
@@ -92,10 +88,10 @@ ifxmips_ifxmips_mii_open(struct net_device *dev)
return 0;
}
-int
-ifxmips_mii_release(struct net_device *dev){
- struct ifxmips_mii_priv* priv = (struct ifxmips_mii_priv*)dev->priv;
- struct dma_device_info* dma_dev = priv->dma_device;
+int ifxmips_mii_release(struct net_device *dev)
+{
+ struct ifxmips_mii_priv *priv = (struct ifxmips_mii_priv *)dev->priv;
+ struct dma_device_info *dma_dev = priv->dma_device;
int i;
for (i = 0; i < dma_dev->max_rx_chan_num; i++)
@@ -104,32 +100,28 @@ ifxmips_mii_release(struct net_device *dev){
return 0;
}
-int
-ifxmips_mii_hw_receive(struct net_device* dev,struct dma_device_info* dma_dev)
+int ifxmips_mii_hw_receive(struct net_device *dev, struct dma_device_info *dma_dev)
{
- struct ifxmips_mii_priv *priv = (struct ifxmips_mii_priv*)dev->priv;
- unsigned char* buf = NULL;
+ struct ifxmips_mii_priv *priv = (struct ifxmips_mii_priv *)dev->priv;
+ unsigned char *buf = NULL;
struct sk_buff *skb = NULL;
int len = 0;
- len = dma_device_read(dma_dev, &buf, (void**)&skb);
+ len = dma_device_read(dma_dev, &buf, (void **)&skb);
- if (len >= ETHERNET_PACKET_DMA_BUFFER_SIZE)
- {
- printk(KERN_INFO "ifxmips_mii0: packet too large %d\n",len);
+ if (len >= ETHERNET_PACKET_DMA_BUFFER_SIZE) {
+ printk(KERN_INFO "ifxmips_mii0: packet too large %d\n", len);
goto ifxmips_mii_hw_receive_err_exit;
}
/* remove CRC */
len -= 4;
- if (skb == NULL)
- {
+ if (skb == NULL) {
printk(KERN_INFO "ifxmips_mii0: cannot restore pointer\n");
goto ifxmips_mii_hw_receive_err_exit;
}
- if (len > (skb->end - skb->tail))
- {
+ if (len > (skb->end - skb->tail)) {
printk(KERN_INFO "ifxmips_mii0: BUG, len:%d end:%p tail:%p\n",
(len+4), skb->end, skb->tail);
goto ifxmips_mii_hw_receive_err_exit;
@@ -145,8 +137,7 @@ ifxmips_mii_hw_receive(struct net_device* dev,struct dma_device_info* dma_dev)
return 0;
ifxmips_mii_hw_receive_err_exit:
- if (len == 0)
- {
+ if (len == 0) {
if (skb)
dev_kfree_skb_any(skb);
priv->stats.rx_errors++;
@@ -157,52 +148,48 @@ ifxmips_mii_hw_receive_err_exit:
}
}
-int
-ifxmips_mii_hw_tx(char *buf, int len, struct net_device *dev)
+int ifxmips_mii_hw_tx(char *buf, int len, struct net_device *dev)
{
int ret = 0;
struct ifxmips_mii_priv *priv = dev->priv;
- struct dma_device_info* dma_dev = priv->dma_device;
+ struct dma_device_info *dma_dev = priv->dma_device;
ret = dma_device_write(dma_dev, buf, len, priv->skb);
return ret;
}
-int
-ifxmips_mii_tx(struct sk_buff *skb, struct net_device *dev)
+int ifxmips_mii_tx(struct sk_buff *skb, struct net_device *dev)
{
int len;
char *data;
struct ifxmips_mii_priv *priv = dev->priv;
- struct dma_device_info* dma_dev = priv->dma_device;
+ struct dma_device_info *dma_dev = priv->dma_device;
len = skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len;
data = skb->data;
priv->skb = skb;
dev->trans_start = jiffies;
- // TODO we got more than 1 dma channel, so we should do something intelligent
- // here to select one
+ /* TODO: we got more than 1 dma channel,
+ so we should do something intelligent here to select one */
dma_dev->current_tx_chan = 0;
wmb();
- if (ifxmips_mii_hw_tx(data, len, dev) != len)
- {
+ if (ifxmips_mii_hw_tx(data, len, dev) != len) {
dev_kfree_skb_any(skb);
priv->stats.tx_errors++;
priv->stats.tx_dropped++;
} else {
priv->stats.tx_packets++;
- priv->stats.tx_bytes+=len;
+ priv->stats.tx_bytes += len;
}
return 0;
}
-void
-ifxmips_mii_tx_timeout(struct net_device *dev)
+void ifxmips_mii_tx_timeout(struct net_device *dev)
{
int i;
- struct ifxmips_mii_priv* priv = (struct ifxmips_mii_priv*)dev->priv;
+ struct ifxmips_mii_priv *priv = (struct ifxmips_mii_priv *)dev->priv;
priv->stats.tx_errors++;
for (i = 0; i < priv->dma_device->max_tx_chan_num; i++)
@@ -211,13 +198,11 @@ ifxmips_mii_tx_timeout(struct net_device *dev)
return;
}
-int
-dma_intr_handler(struct dma_device_info* dma_dev, int status)
+int dma_intr_handler(struct dma_device_info *dma_dev, int status)
{
int i;
- switch(status)
- {
+ switch (status) {
case RCV_INT:
ifxmips_mii_hw_receive(ifxmips_mii0_dev, dma_dev);
break;
@@ -225,9 +210,8 @@ dma_intr_handler(struct dma_device_info* dma_dev, int status)
case TX_BUF_FULL_INT:
printk(KERN_INFO "ifxmips_mii0: tx buffer full\n");
netif_stop_queue(ifxmips_mii0_dev);
- for (i = 0; i < dma_dev->max_tx_chan_num; i++)
- {
- if ((dma_dev->tx_chan[i])->control==IFXMIPS_DMA_CH_ON)
+ for (i = 0; i < dma_dev->max_tx_chan_num; i++) {
+ if ((dma_dev->tx_chan[i])->control == IFXMIPS_DMA_CH_ON)
dma_dev->tx_chan[i]->enable_irq(dma_dev->tx_chan[i]);
}
break;
@@ -243,8 +227,7 @@ dma_intr_handler(struct dma_device_info* dma_dev, int status)
return 0;
}
-unsigned char*
-ifxmips_etop_dma_buffer_alloc(int len, int *byte_offset, void **opt)
+unsigned char *ifxmips_etop_dma_buffer_alloc(int len, int *byte_offset, void **opt)
{
unsigned char *buffer = NULL;
struct sk_buff *skb = NULL;
@@ -253,36 +236,32 @@ ifxmips_etop_dma_buffer_alloc(int len, int *byte_offset, void **opt)
if (skb == NULL)
return NULL;
- buffer = (unsigned char*)(skb->data);
+ buffer = (unsigned char *)(skb->data);
skb_reserve(skb, 2);
- *(int*)opt = (int)skb;
+ *(int *)opt = (int)skb;
*byte_offset = 2;
return buffer;
}
-void
-ifxmips_etop_dma_buffer_free(unsigned char *dataptr, void *opt)
+void ifxmips_etop_dma_buffer_free(unsigned char *dataptr, void *opt)
{
struct sk_buff *skb = NULL;
- if (opt == NULL)
- {
+ if (opt == NULL) {
kfree(dataptr);
} else {
- skb = (struct sk_buff*)opt;
+ skb = (struct sk_buff *)opt;
dev_kfree_skb_any(skb);
}
}
-static struct net_device_stats*
-ifxmips_get_stats(struct net_device *dev)
+static struct net_device_stats *ifxmips_get_stats(struct net_device *dev)
{
return (struct net_device_stats *)dev->priv;
}
-static int
-ifxmips_mii_dev_init(struct net_device *dev)
+static int ifxmips_mii_dev_init(struct net_device *dev)
{
int i;
struct ifxmips_mii_priv *priv;
@@ -298,7 +277,7 @@ ifxmips_mii_dev_init(struct net_device *dev)
memset(dev->priv, 0, sizeof(struct ifxmips_mii_priv));
priv = dev->priv;
priv->dma_device = dma_device_reserve("PPE");
- if (!priv->dma_device){
+ if (!priv->dma_device) {
BUG();
return -ENODEV;
}
@@ -307,8 +286,7 @@ ifxmips_mii_dev_init(struct net_device *dev)
priv->dma_device->intr_handler = &dma_intr_handler;
priv->dma_device->max_rx_chan_num = 4;
- for (i = 0; i < priv->dma_device->max_rx_chan_num; i++)
- {
+ for (i = 0; i < priv->dma_device->max_rx_chan_num; i++) {
priv->dma_device->rx_chan[i]->packet_size = ETHERNET_PACKET_DMA_BUFFER_SIZE;
priv->dma_device->rx_chan[i]->control = IFXMIPS_DMA_CH_ON;
}
@@ -322,16 +300,14 @@ ifxmips_mii_dev_init(struct net_device *dev)
dma_device_register(priv->dma_device);
printk(KERN_INFO "ifxmips_mii0: using mac=");
- for (i = 0; i < 6; i++)
- {
+ for (i = 0; i < 6; i++) {
dev->dev_addr[i] = mac_addr[i];
printk("%02X%c", dev->dev_addr[i], (i == 5)?('\n'):(':'));
}
return 0;
}
-static void
-ifxmips_mii_chip_init(int mode)
+static void ifxmips_mii_chip_init(int mode)
{
ifxmips_pmu_enable(IFXMIPS_PMU_PWDCR_DMA);
ifxmips_pmu_enable(IFXMIPS_PMU_PWDCR_PPE);
@@ -345,19 +321,17 @@ ifxmips_mii_chip_init(int mode)
wmb();
}
-static int
-ifxmips_mii_probe(struct platform_device *dev)
+static int ifxmips_mii_probe(struct platform_device *dev)
{
int result = 0;
- unsigned char *mac = (unsigned char*)dev->dev.platform_data;
+ unsigned char *mac = (unsigned char *)dev->dev.platform_data;
ifxmips_mii0_dev = alloc_etherdev(sizeof(struct ifxmips_mii_priv));
ifxmips_mii0_dev->init = ifxmips_mii_dev_init;
memcpy(mac_addr, mac, 6);
strcpy(ifxmips_mii0_dev->name, "eth%d");
ifxmips_mii_chip_init(REV_MII_MODE);
result = register_netdev(ifxmips_mii0_dev);
- if (result)
- {
+ if (result) {
printk(KERN_INFO "ifxmips_mii0: error %i registering device \"%s\"\n", result, ifxmips_mii0_dev->name);
goto out;
}
@@ -368,10 +342,9 @@ out:
return result;
}
-static int
-ifxmips_mii_remove(struct platform_device *dev)
+static int ifxmips_mii_remove(struct platform_device *dev)
{
- struct ifxmips_mii_priv *priv = (struct ifxmips_mii_priv*)ifxmips_mii0_dev->priv;
+ struct ifxmips_mii_priv *priv = (struct ifxmips_mii_priv *)ifxmips_mii0_dev->priv;
printk(KERN_INFO "ifxmips_mii0: ifxmips_mii0 cleanup\n");
@@ -383,8 +356,7 @@ ifxmips_mii_remove(struct platform_device *dev)
return 0;
}
-static struct
-platform_driver ifxmips_mii_driver = {
+static struct platform_driver ifxmips_mii_driver = {
.probe = ifxmips_mii_probe,
.remove = ifxmips_mii_remove,
.driver = {
@@ -393,8 +365,7 @@ platform_driver ifxmips_mii_driver = {
},
};
-int __init
-ifxmips_mii_init(void)
+int __init ifxmips_mii_init(void)
{
int ret = platform_driver_register(&ifxmips_mii_driver);
if (ret)
@@ -402,8 +373,7 @@ ifxmips_mii_init(void)
return ret;
}
-static void __exit
-ifxmips_mii_cleanup(void)
+static void __exit ifxmips_mii_cleanup(void)
{
platform_driver_unregister(&ifxmips_mii_driver);
}
@@ -414,3 +384,4 @@ module_exit(ifxmips_mii_cleanup);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("John Crispin <blogic@openwrt.org>");
MODULE_DESCRIPTION("ethernet map driver for IFXMIPS boards");
+
diff --git a/target/linux/ifxmips/files/drivers/serial/ifxmips_asc.c b/target/linux/ifxmips/files/drivers/serial/ifxmips_asc.c
index 2dc8917fe..d6bf1803f 100644
--- a/target/linux/ifxmips/files/drivers/serial/ifxmips_asc.c
+++ b/target/linux/ifxmips/files/drivers/serial/ifxmips_asc.c
@@ -42,10 +42,12 @@
#include <linux/sysrq.h>
#include <linux/irq.h>
#include <linux/platform_device.h>
+#include <linux/io.h>
+#include <linux/uaccess.h>
+#include <linux/bitops.h>
+
#include <asm/system.h>
-#include <asm/io.h>
-#include <asm/uaccess.h>
-#include <asm/bitops.h>
+
#include <asm/ifxmips/ifxmips.h>
#include <asm/ifxmips/ifxmips_irq.h>
@@ -56,19 +58,17 @@
#define UART_DUMMY_UER_RX 1
static void ifxmipsasc_tx_chars(struct uart_port *port);
-extern void prom_printf(const char * fmt, ...);
+extern void prom_printf(const char *fmt, ...);
static struct uart_port ifxmipsasc_port[2];
static struct uart_driver ifxmipsasc_reg;
extern unsigned int ifxmips_get_fpi_hz(void);
-static void
-ifxmipsasc_stop_tx(struct uart_port *port)
+static void ifxmipsasc_stop_tx(struct uart_port *port)
{
return;
}
-static void
-ifxmipsasc_start_tx(struct uart_port *port)
+static void ifxmipsasc_start_tx(struct uart_port *port)
{
unsigned long flags;
local_irq_save(flags);
@@ -77,26 +77,28 @@ ifxmipsasc_start_tx(struct uart_port *port)
return;
}
-static void
-ifxmipsasc_stop_rx(struct uart_port *port)
+static void ifxmipsasc_stop_rx(struct uart_port *port)
{
ifxmips_w32(ASCWHBSTATE_CLRREN, port->membase + IFXMIPS_ASC_WHBSTATE);
}
-static void
-ifxmipsasc_enable_ms(struct uart_port *port)
+static void ifxmipsasc_enable_ms(struct uart_port *port)
{
}
-static void
-ifxmipsasc_rx_chars(struct uart_port *port)
+#include <linux/version.h>
+
+static void ifxmipsasc_rx_chars(struct uart_port *port)
{
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 26))
+ struct tty_struct *tty = port->info->port.tty;
+#else
struct tty_struct *tty = port->info->tty;
+#endif
unsigned int ch = 0, rsr = 0, fifocnt;
fifocnt = ifxmips_r32(port->membase + IFXMIPS_ASC_FSTAT) & ASCFSTAT_RXFFLMASK;
- while(fifocnt--)
- {
+ while (fifocnt--) {
u8 flag = TTY_NORMAL;
ch = ifxmips_r32(port->membase + IFXMIPS_ASC_RBUF);
rsr = (ifxmips_r32(port->membase + IFXMIPS_ASC_STATE) & ASCSTATE_ANY) | UART_DUMMY_UER_RX;
@@ -107,35 +109,31 @@ ifxmipsasc_rx_chars(struct uart_port *port)
* Note that the error handling code is
* out of the main execution path
*/
- if(rsr & ASCSTATE_ANY)
- {
- if(rsr & ASCSTATE_PE)
- {
+ if (rsr & ASCSTATE_ANY) {
+ if (rsr & ASCSTATE_PE) {
port->icount.parity++;
ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_WHBSTATE) | ASCWHBSTATE_CLRPE, port->membase + IFXMIPS_ASC_WHBSTATE);
- } else if(rsr & ASCSTATE_FE)
- {
+ } else if (rsr & ASCSTATE_FE) {
port->icount.frame++;
ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_WHBSTATE) | ASCWHBSTATE_CLRFE, port->membase + IFXMIPS_ASC_WHBSTATE);
}
- if(rsr & ASCSTATE_ROE)
- {
+ if (rsr & ASCSTATE_ROE) {
port->icount.overrun++;
ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_WHBSTATE) | ASCWHBSTATE_CLRROE, port->membase + IFXMIPS_ASC_WHBSTATE);
}
rsr &= port->read_status_mask;
- if(rsr & ASCSTATE_PE)
+ if (rsr & ASCSTATE_PE)
flag = TTY_PARITY;
- else if(rsr & ASCSTATE_FE)
+ else if (rsr & ASCSTATE_FE)
flag = TTY_FRAME;
}
- if((rsr & port->ignore_status_mask) == 0)
+ if ((rsr & port->ignore_status_mask) == 0)
tty_insert_flip_char(tty, ch, flag);
- if(rsr & ASCSTATE_ROE)
+ if (rsr & ASCSTATE_ROE)
/*
* Overrun is special, since it's reported
* immediately, and doesn't affect the current
@@ -143,34 +141,30 @@ ifxmipsasc_rx_chars(struct uart_port *port)
*/
tty_insert_flip_char(tty, 0, TTY_OVERRUN);
}
- if(ch != 0)
+ if (ch != 0)
tty_flip_buffer_push(tty);
return;
}
-static void
-ifxmipsasc_tx_chars(struct uart_port *port)
+static void ifxmipsasc_tx_chars(struct uart_port *port)
{
struct circ_buf *xmit = &port->info->xmit;
- if(uart_tx_stopped(port))
- {
+ if (uart_tx_stopped(port)) {
ifxmipsasc_stop_tx(port);
return;
}
- while(((ifxmips_r32(port->membase + IFXMIPS_ASC_FSTAT) & ASCFSTAT_TXFFLMASK)
- >> ASCFSTAT_TXFFLOFF) != TXFIFO_FULL)
- {
- if(port->x_char)
- {
+ while (((ifxmips_r32(port->membase + IFXMIPS_ASC_FSTAT) & ASCFSTAT_TXFFLMASK)
+ >> ASCFSTAT_TXFFLOFF) != TXFIFO_FULL) {
+ if (port->x_char) {
ifxmips_w32(port->x_char, port->membase + IFXMIPS_ASC_TBUF);
port->icount.tx++;
port->x_char = 0;
continue;
}
- if(uart_circ_empty(xmit))
+ if (uart_circ_empty(xmit))
break;
ifxmips_w32(port->info->xmit.buf[port->info->xmit.tail], port->membase + IFXMIPS_ASC_TBUF);
@@ -178,66 +172,58 @@ ifxmipsasc_tx_chars(struct uart_port *port)
port->icount.tx++;
}
- if(uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
+ if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
uart_write_wakeup(port);
}
-static irqreturn_t
-ifxmipsasc_tx_int(int irq, void *_port)
+static irqreturn_t ifxmipsasc_tx_int(int irq, void *_port)
{
- struct uart_port *port = (struct uart_port*) _port;
+ struct uart_port *port = (struct uart_port *)_port;
ifxmips_w32(ASC_IRNCR_TIR, port->membase + IFXMIPS_ASC_IRNCR);
ifxmipsasc_start_tx(port);
ifxmips_mask_and_ack_irq(irq);
return IRQ_HANDLED;
}
-static irqreturn_t
-ifxmipsasc_er_int(int irq, void *_port)
+static irqreturn_t ifxmipsasc_er_int(int irq, void *_port)
{
- struct uart_port *port = (struct uart_port*) _port;
+ struct uart_port *port = (struct uart_port *)_port;
/* clear any pending interrupts */
ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_WHBSTATE) | ASCWHBSTATE_CLRPE |
ASCWHBSTATE_CLRFE | ASCWHBSTATE_CLRROE, port->membase + IFXMIPS_ASC_WHBSTATE);
return IRQ_HANDLED;
}
-static irqreturn_t
-ifxmipsasc_rx_int(int irq, void *_port)
+static irqreturn_t ifxmipsasc_rx_int(int irq, void *_port)
{
- struct uart_port *port = (struct uart_port*)_port;
+ struct uart_port *port = (struct uart_port *)_port;
ifxmips_w32(ASC_IRNCR_RIR, port->membase + IFXMIPS_ASC_IRNCR);
- ifxmipsasc_rx_chars((struct uart_port*)port);
+ ifxmipsasc_rx_chars((struct uart_port *)port);
ifxmips_mask_and_ack_irq(irq);
return IRQ_HANDLED;
}
-static unsigned int
-ifxmipsasc_tx_empty(struct uart_port *port)
+static unsigned int ifxmipsasc_tx_empty(struct uart_port *port)
{
int status;
status = ifxmips_r32(port->membase + IFXMIPS_ASC_FSTAT) & ASCFSTAT_TXFFLMASK;
return status ? 0 : TIOCSER_TEMT;
}
-static unsigned int
-ifxmipsasc_get_mctrl(struct uart_port *port)
+static unsigned int ifxmipsasc_get_mctrl(struct uart_port *port)
{
return TIOCM_CTS | TIOCM_CAR | TIOCM_DSR;
}
-static void
-ifxmipsasc_set_mctrl(struct uart_port *port, u_int mctrl)
+static void ifxmipsasc_set_mctrl(struct uart_port *port, u_int mctrl)
{
}
-static void
-ifxmipsasc_break_ctl(struct uart_port *port, int break_state)
+static void ifxmipsasc_break_ctl(struct uart_port *port, int break_state)
{
}
-static int
-ifxmipsasc_startup(struct uart_port *port)
+static int ifxmipsasc_startup(struct uart_port *port)
{
unsigned long flags;
int retval;
@@ -249,29 +235,26 @@ ifxmipsasc_startup(struct uart_port *port)
ifxmips_w32(0, port->membase + IFXMIPS_ASC_PISEL);
ifxmips_w32(((TXFIFO_FL << ASCTXFCON_TXFITLOFF) & ASCTXFCON_TXFITLMASK) | ASCTXFCON_TXFEN | ASCTXFCON_TXFFLU, port->membase + IFXMIPS_ASC_TXFCON);
ifxmips_w32(((RXFIFO_FL << ASCRXFCON_RXFITLOFF) & ASCRXFCON_RXFITLMASK) | ASCRXFCON_RXFEN | ASCRXFCON_RXFFLU, port->membase + IFXMIPS_ASC_RXFCON);
- wmb ();
+ wmb();
ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_CON) | ASCCON_M_8ASYNC | ASCCON_FEN | ASCCON_TOEN | ASCCON_ROEN, port->membase + IFXMIPS_ASC_CON);
local_irq_save(flags);
retval = request_irq(port->irq, ifxmipsasc_tx_int, IRQF_DISABLED, "asc_tx", port);
- if(retval)
- {
- printk("failed to request ifxmipsasc_tx_int\n");
+ if (retval) {
+ printk(KERN_ERR "failed to request ifxmipsasc_tx_int\n");
return retval;
}
retval = request_irq(port->irq + 2, ifxmipsasc_rx_int, IRQF_DISABLED, "asc_rx", port);
- if(retval)
- {
- printk("failed to request ifxmipsasc_rx_int\n");
+ if (retval) {
+ printk(KERN_ERR "failed to request ifxmipsasc_rx_int\n");
goto err1;
}
retval = request_irq(port->irq + 3, ifxmipsasc_er_int, IRQF_DISABLED, "asc_er", port);
- if(retval)
- {
- printk("failed to request ifxmipsasc_er_int\n");
+ if (retval) {
+ printk(KERN_ERR "failed to request ifxmipsasc_er_int\n");
goto err2;
}
@@ -288,8 +271,7 @@ err1:
return retval;
}
-static void
-ifxmipsasc_shutdown(struct uart_port *port)
+static void ifxmipsasc_shutdown(struct uart_port *port)
{
free_irq(port->irq, port);
free_irq(port->irq + 2, port);
@@ -314,8 +296,7 @@ static void ifxmipsasc_set_termios(struct uart_port *port, struct ktermios *new,
cflag = new->c_cflag;
iflag = new->c_iflag;
- switch(cflag & CSIZE)
- {
+ switch (cflag & CSIZE) {
case CS7:
con = ASCCON_M_7ASYNC;
break;
@@ -327,36 +308,34 @@ static void ifxmipsasc_set_termios(struct uart_port *port, struct ktermios *new,
break;
}
- if(cflag & CSTOPB)
+ if (cflag & CSTOPB)
con |= ASCCON_STP;
- if(cflag & PARENB)
- {
- if(!(cflag & PARODD))
+ if (cflag & PARENB) {
+ if (!(cflag & PARODD))
con &= ~ASCCON_ODD;
else
con |= ASCCON_ODD;
}
port->read_status_mask = ASCSTATE_ROE;
- if(iflag & INPCK)
+ if (iflag & INPCK)
port->read_status_mask |= ASCSTATE_FE | ASCSTATE_PE;
port->ignore_status_mask = 0;
- if(iflag & IGNPAR)
+ if (iflag & IGNPAR)
port->ignore_status_mask |= ASCSTATE_FE | ASCSTATE_PE;
- if(iflag & IGNBRK)
- {
+ if (iflag & IGNBRK) {
/*
* If we're ignoring parity and break indicators,
* ignore overruns too (for real raw support).
*/
- if(iflag & IGNPAR)
+ if (iflag & IGNPAR)
port->ignore_status_mask |= ASCSTATE_ROE;
}
- if((cflag & CREAD) == 0)
+ if ((cflag & CREAD) == 0)
port->ignore_status_mask |= UART_DUMMY_UER_RX;
/* set error signals - framing, parity and overrun, enable receiver */
@@ -368,7 +347,7 @@ static void ifxmipsasc_set_termios(struct uart_port *port, struct ktermios *new,
ifxmips_w32(ifxmips_r32(port->membase + IFXMIPS_ASC_CON) | con, port->membase + IFXMIPS_ASC_CON);
/* Set baud rate - take a divider of 2 into account */
- baud = uart_get_baud_rate(port, new, old, 0, port->uartclk / 16);
+ baud = uart_get_baud_rate(port, new, old, 0, port->uartclk / 16);
quot = uart_get_divisor(port, baud);
quot = quot / 2 - 1;
@@ -393,12 +372,10 @@ static void ifxmipsasc_set_termios(struct uart_port *port, struct ktermios *new,
local_irq_restore(flags);
}
-static const char*
-ifxmipsasc_type(struct uart_port *port)
+static const char *ifxmipsasc_type(struct uart_port *port)
{
- if(port->type == PORT_IFXMIPSASC)
- {
- if(port->membase == (void*)IFXMIPS_ASC_BASE_ADDR)
+ if (port->type == PORT_IFXMIPSASC) {
+ if (port->membase == (void *)IFXMIPS_ASC_BASE_ADDR)
return "asc0";
else
return "asc1";
@@ -407,120 +384,109 @@ ifxmipsasc_type(struct uart_port *port)
}
}
-static void
-ifxmipsasc_release_port(struct uart_port *port)
+static void ifxmipsasc_release_port(struct uart_port *port)
{
}
-static int
-ifxmipsasc_request_port(struct uart_port *port)
+static int ifxmipsasc_request_port(struct uart_port *port)
{
return 0;
}
-static void
-ifxmipsasc_config_port(struct uart_port *port, int flags)
+static void ifxmipsasc_config_port(struct uart_port *port, int flags)
{
- if(flags & UART_CONFIG_TYPE)
- {
+ if (flags & UART_CONFIG_TYPE) {
port->type = PORT_IFXMIPSASC;
ifxmipsasc_request_port(port);
}
}
-static int
-ifxmipsasc_verify_port(struct uart_port *port, struct serial_struct *ser)
+static int ifxmipsasc_verify_port(struct uart_port *port, struct serial_struct *ser)
{
int ret = 0;
- if(ser->type != PORT_UNKNOWN && ser->type != PORT_IFXMIPSASC)
+ if (ser->type != PORT_UNKNOWN && ser->type != PORT_IFXMIPSASC)
ret = -EINVAL;
- if(ser->irq < 0 || ser->irq >= NR_IRQS)
+ if (ser->irq < 0 || ser->irq >= NR_IRQS)
ret = -EINVAL;
- if(ser->baud_base < 9600)
+ if (ser->baud_base < 9600)
ret = -EINVAL;
return ret;
}
-static struct uart_ops ifxmipsasc_pops =
-{
- .tx_empty = ifxmipsasc_tx_empty,
+static struct uart_ops ifxmipsasc_pops = {
+ .tx_empty = ifxmipsasc_tx_empty,
.set_mctrl = ifxmipsasc_set_mctrl,
.get_mctrl = ifxmipsasc_get_mctrl,
- .stop_tx = ifxmipsasc_stop_tx,
- .start_tx = ifxmipsasc_start_tx,
- .stop_rx = ifxmipsasc_stop_rx,
+ .stop_tx = ifxmipsasc_stop_tx,
+ .start_tx = ifxmipsasc_start_tx,
+ .stop_rx = ifxmipsasc_stop_rx,
.enable_ms = ifxmipsasc_enable_ms,
.break_ctl = ifxmipsasc_break_ctl,
- .startup = ifxmipsasc_startup,
- .shutdown = ifxmipsasc_shutdown,
+ .startup = ifxmipsasc_startup,
+ .shutdown = ifxmipsasc_shutdown,
.set_termios = ifxmipsasc_set_termios,
- .type = ifxmipsasc_type,
+ .type = ifxmipsasc_type,
.release_port = ifxmipsasc_release_port,
.request_port = ifxmipsasc_request_port,
.config_port = ifxmipsasc_config_port,
.verify_port = ifxmipsasc_verify_port,
};
-static struct uart_port ifxmipsasc_port[2] =
-{
+static struct uart_port ifxmipsasc_port[2] = {
{
- membase: (void *)IFXMIPS_ASC_BASE_ADDR,
- mapbase: IFXMIPS_ASC_BASE_ADDR,
- iotype: SERIAL_IO_MEM,
- irq: IFXMIPSASC_TIR(0),
- uartclk: 0,
- fifosize: 16,
- type: PORT_IFXMIPSASC,
- ops: &ifxmipsasc_pops,
- flags: ASYNC_BOOT_AUTOCONF,
- line: 0
+ .membase = (void *)IFXMIPS_ASC_BASE_ADDR,
+ .mapbase = IFXMIPS_ASC_BASE_ADDR,
+ .iotype = SERIAL_IO_MEM,
+ .irq = IFXMIPSASC_TIR(0),
+ .uartclk = 0,
+ .fifosize = 16,
+ .type = PORT_IFXMIPSASC,
+ .ops = &ifxmipsasc_pops,
+ .flags = ASYNC_BOOT_AUTOCONF,
+ .line = 0
}, {
- membase: (void *)(IFXMIPS_ASC_BASE_ADDR + IFXMIPS_ASC_BASE_DIFF),
- mapbase: IFXMIPS_ASC_BASE_ADDR + IFXMIPS_ASC_BASE_DIFF,
- iotype: SERIAL_IO_MEM,
- irq: IFXMIPSASC_TIR(1),
- uartclk: 0,
- fifosize: 16,
- type: PORT_IFXMIPSASC,
- ops: &ifxmipsasc_pops,
- flags: ASYNC_BOOT_AUTOCONF,
- line: 1
+ .membase = (void *)(IFXMIPS_ASC_BASE_ADDR + IFXMIPS_ASC_BASE_DIFF),
+ .mapbase = IFXMIPS_ASC_BASE_ADDR + IFXMIPS_ASC_BASE_DIFF,
+ .iotype = SERIAL_IO_MEM,
+ .irq = IFXMIPSASC_TIR(1),
+ .uartclk = 0,
+ .fifosize = 16,
+ .type = PORT_IFXMIPSASC,
+ .ops = &ifxmipsasc_pops,
+ .flags = ASYNC_BOOT_AUTOCONF,
+ .line = 1
}
};
-static void
-ifxmipsasc_console_write(struct console *co, const char *s, u_int count)
+static void ifxmipsasc_console_write(struct console *co, const char *s, u_int count)
{
int port = co->index;
int i, fifocnt;
unsigned long flags;
local_irq_save(flags);
- for(i = 0; i < count; i++)
- {
+ for (i = 0; i < count; i++) {
do {
- fifocnt = (ifxmips_r32((u32*)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_FSTAT)) & ASCFSTAT_TXFFLMASK)
- >> ASCFSTAT_TXFFLOFF;
- } while(fifocnt == TXFIFO_FULL);
+ fifocnt = (ifxmips_r32((u32 *)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_FSTAT)) & ASCFSTAT_TXFFLMASK)
+ >> ASCFSTAT_TXFFLOFF;
+ } while (fifocnt == TXFIFO_FULL);
- if(s[i] == '\0')
+ if (s[i] == '\0')
break;
- if(s[i] == '\n')
- {
- ifxmips_w32('\r', (u32*)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_TBUF));
+ if (s[i] == '\n') {
+ ifxmips_w32('\r', (u32 *)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_TBUF));
do {
- fifocnt = (ifxmips_r32((u32*)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_FSTAT)) & ASCFSTAT_TXFFLMASK)
+ fifocnt = (ifxmips_r32((u32 *)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_FSTAT)) & ASCFSTAT_TXFFLMASK)
>> ASCFSTAT_TXFFLOFF;
- } while(fifocnt == TXFIFO_FULL);
+ } while (fifocnt == TXFIFO_FULL);
}
- ifxmips_w32(s[i], (u32*)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_TBUF));
+ ifxmips_w32(s[i], (u32 *)(IFXMIPS_ASC_BASE_ADDR + (port * IFXMIPS_ASC_BASE_DIFF) + IFXMIPS_ASC_TBUF));
}
local_irq_restore(flags);
}
-static int __init
-ifxmipsasc_console_setup(struct console *co, char *options)
+static int __init ifxmipsasc_console_setup(struct console *co, char *options)
{
int port = co->index;
int baud = 115200;
@@ -529,7 +495,7 @@ ifxmipsasc_console_setup(struct console *co, char *options)
int flow = 'n';
ifxmipsasc_port[port].uartclk = ifxmips_get_fpi_hz();
ifxmipsasc_port[port].type = PORT_IFXMIPSASC;
- if(options)
+ if (options)
uart_parse_options(options, &baud, &parity, &bits, &flow);
return uart_set_options(&ifxmipsasc_port[port], co, baud, parity, bits, flow);
}
@@ -537,26 +503,25 @@ ifxmipsasc_console_setup(struct console *co, char *options)
static struct console ifxmipsasc_console[2] =
{
{
- name: "ttyS",
- write: ifxmipsasc_console_write,
- device: uart_console_device,
- setup: ifxmipsasc_console_setup,
- flags: CON_PRINTBUFFER,
- index: 0,
- data: &ifxmipsasc_reg,
+ .name = "ttyS",
+ .write = ifxmipsasc_console_write,
+ .device = uart_console_device,
+ .setup = ifxmipsasc_console_setup,
+ .flags = CON_PRINTBUFFER,
+ .index = 0,
+ .data = &ifxmipsasc_reg,
}, {
- name: "ttyS",
- write: ifxmipsasc_console_write,
- device: uart_console_device,
- setup: ifxmipsasc_console_setup,
- flags: CON_PRINTBUFFER,
- index: 1,
- data: &ifxmipsasc_reg,
+ .name = "ttyS",
+ .write = ifxmipsasc_console_write,
+ .device = uart_console_device,
+ .setup = ifxmipsasc_console_setup,
+ .flags = CON_PRINTBUFFER,
+ .index = 1,
+ .data = &ifxmipsasc_reg,
}
};
-static int __init
-ifxmipsasc_console_init(void)
+static int __init ifxmipsasc_console_init(void)
{
register_console(&ifxmipsasc_console[0]);
register_console(&ifxmipsasc_console[1]);
@@ -564,19 +529,17 @@ ifxmipsasc_console_init(void)
}
console_initcall(ifxmipsasc_console_init);
-static struct uart_driver ifxmipsasc_reg =
-{
- .owner = THIS_MODULE,
- .driver_name = "serial",
- .dev_name = "ttyS",
- .major = TTY_MAJOR,
- .minor = 64,
- .nr = 2,
- .cons = &ifxmipsasc_console[1],
+static struct uart_driver ifxmipsasc_reg = {
+ .owner = THIS_MODULE,
+ .driver_name = "serial",
+ .dev_name = "ttyS",
+ .major = TTY_MAJOR,
+ .minor = 64,
+ .nr = 2,
+ .cons = &ifxmipsasc_console[1],
};
-int __init
-ifxmipsasc_init(void)
+int __init ifxmipsasc_init(void)
{
int ret;
uart_register_driver(&ifxmipsasc_reg);
@@ -585,8 +548,7 @@ ifxmipsasc_init(void)
return 0;
}
-void __exit
-ifxmipsasc_exit(void)
+void __exit ifxmipsasc_exit(void)
{
uart_unregister_driver(&ifxmipsasc_reg);
}