diff options
author | matteo <matteo@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2007-09-11 21:19:57 +0000 |
---|---|---|
committer | matteo <matteo@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2007-09-11 21:19:57 +0000 |
commit | 6485c8ba0a21f44100aa96123f2edd70fe9edbe6 (patch) | |
tree | b97ce2d7c30acc1ff98fc64889cd3c40ea97218d /target | |
parent | 02c9cd23690727767b933f700a10296d18b47a84 (diff) |
AR7: Cleanups (closes: #2323)
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@8756 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target')
20 files changed, 447 insertions, 483 deletions
diff --git a/target/linux/ar7/files/arch/mips/ar7/clock.c b/target/linux/ar7/files/arch/mips/ar7/clock.c index 56ade75ac..055cd5be9 100644 --- a/target/linux/ar7/files/arch/mips/ar7/clock.c +++ b/target/linux/ar7/files/arch/mips/ar7/clock.c @@ -1,18 +1,16 @@ /* - * $Id$ - * * Copyright (C) 2007 OpenWrt.org - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -96,7 +94,7 @@ int ar7_cpu_clock = 150000000; EXPORT_SYMBOL(ar7_cpu_clock); int ar7_bus_clock = 125000000; EXPORT_SYMBOL(ar7_bus_clock); -int ar7_dsp_clock = 0; +int ar7_dsp_clock; EXPORT_SYMBOL(ar7_dsp_clock); static int gcd(int a, int b) @@ -212,7 +210,7 @@ static int tnetd7300_get_clock(u32 shift, struct tnetd7300_clock *clock, return (base_clock >> (mul / 16 + 1)) / divisor; if ((pll & (PLL_NDIV | PLL_DIV)) == (PLL_NDIV | PLL_DIV)) { - product = (mul & 1) ? + product = (mul & 1) ? (base_clock * mul) >> 1 : (base_clock * (mul - 1)) >> 2; return product / divisor; @@ -261,21 +259,24 @@ static void tnetd7300_set_clock(u32 shift, struct tnetd7300_clock *clock, static void __init tnetd7300_init_clocks(void) { u32 *bootcr = (u32 *)ioremap_nocache(AR7_REGS_DCL, 4); - struct tnetd7300_clocks *clocks = (struct tnetd7300_clocks *)ioremap_nocache(AR7_REGS_POWER + 0x20, sizeof(struct tnetd7300_clocks)); + struct tnetd7300_clocks *clocks = + (struct tnetd7300_clocks *) + ioremap_nocache(AR7_REGS_POWER + 0x20, + sizeof(struct tnetd7300_clocks)); - ar7_bus_clock = tnetd7300_get_clock(BUS_PLL_SOURCE_SHIFT, + ar7_bus_clock = tnetd7300_get_clock(BUS_PLL_SOURCE_SHIFT, &clocks->bus, bootcr, AR7_AFE_CLOCK); if (*bootcr & BOOT_PLL_ASYNC_MODE) { - ar7_cpu_clock = tnetd7300_get_clock(CPU_PLL_SOURCE_SHIFT, + ar7_cpu_clock = tnetd7300_get_clock(CPU_PLL_SOURCE_SHIFT, &clocks->cpu, bootcr, AR7_AFE_CLOCK); } else { ar7_cpu_clock = ar7_bus_clock; } -#if 0 +/* tnetd7300_set_clock(USB_PLL_SOURCE_SHIFT, &clocks->usb, bootcr, 48000000); -#endif +*/ if (ar7_dsp_clock == 250000000) tnetd7300_set_clock(DSP_PLL_SOURCE_SHIFT, &clocks->dsp, bootcr, ar7_dsp_clock); @@ -287,7 +288,7 @@ static void __init tnetd7300_init_clocks(void) static int tnetd7200_get_clock(int base, struct tnetd7200_clock *clock, u32 *bootcr, u32 bus_clock) { - int divisor = ((clock->prediv & 0x1f) + 1) * + int divisor = ((clock->prediv & 0x1f) + 1) * ((clock->postdiv & 0x1f) + 1); if (*bootcr & BOOT_PLL_BYPASS) @@ -300,30 +301,32 @@ static int tnetd7200_get_clock(int base, struct tnetd7200_clock *clock, static void tnetd7200_set_clock(int base, struct tnetd7200_clock *clock, int prediv, int postdiv, int postdiv2, int mul, u32 frequency) { - printk("Clocks: base = %d, frequency = %u, prediv = %d, postdiv = %d, postdiv2 = %d, mul = %d\n", + printk(KERN_INFO + "Clocks: base = %d, frequency = %u, prediv = %d, " + "postdiv = %d, postdiv2 = %d, mul = %d\n", base, frequency, prediv, postdiv, postdiv2, mul); clock->ctrl = 0; clock->prediv = DIVISOR_ENABLE_MASK | ((prediv - 1) & 0x1F); clock->mul = ((mul - 1) & 0xF); - for(mul = 0; mul < 2000; mul++) /* nop */; + for (mul = 0; mul < 2000; mul++) /* nop */; - while(clock->status & 0x1) /* nop */; + while (clock->status & 0x1) /* nop */; clock->postdiv = DIVISOR_ENABLE_MASK | ((postdiv - 1) & 0x1F); clock->cmden |= 1; clock->cmd |= 1; - while(clock->status & 0x1) /* nop */; + while (clock->status & 0x1) /* nop */; clock->postdiv2 = DIVISOR_ENABLE_MASK | ((postdiv2 - 1) & 0x1F); clock->cmden |= 1; clock->cmd |= 1; - while(clock->status & 0x1) /* nop */; + while (clock->status & 0x1) /* nop */; clock->ctrl |= 1; } @@ -331,7 +334,7 @@ static void tnetd7200_set_clock(int base, struct tnetd7200_clock *clock, static int tnetd7200_get_clock_base(int clock_id, u32 *bootcr) { if (*bootcr & BOOT_PLL_ASYNC_MODE) { - // Async + /* Async */ switch (clock_id) { case TNETD7200_CLOCK_ID_DSP: return AR7_REF_CLOCK; @@ -339,9 +342,9 @@ static int tnetd7200_get_clock_base(int clock_id, u32 *bootcr) return AR7_AFE_CLOCK; } } else { - // Sync + /* Sync */ if (*bootcr & BOOT_PLL_2TO1_MODE) { - // 2:1 + /* 2:1 */ switch (clock_id) { case TNETD7200_CLOCK_ID_DSP: return AR7_REF_CLOCK; @@ -349,7 +352,7 @@ static int tnetd7200_get_clock_base(int clock_id, u32 *bootcr) return AR7_AFE_CLOCK; } } else { - // 1:1 + /* 1:1 */ return AR7_REF_CLOCK; } } @@ -359,7 +362,10 @@ static int tnetd7200_get_clock_base(int clock_id, u32 *bootcr) static void __init tnetd7200_init_clocks(void) { u32 *bootcr = (u32 *)ioremap_nocache(AR7_REGS_DCL, 4); - struct tnetd7200_clocks *clocks = (struct tnetd7200_clocks *)ioremap_nocache(AR7_REGS_POWER + 0x80, sizeof(struct tnetd7200_clocks)); + struct tnetd7200_clocks *clocks = + (struct tnetd7200_clocks *) + ioremap_nocache(AR7_REGS_POWER + 0x80, + sizeof(struct tnetd7200_clocks)); int cpu_base, cpu_mul, cpu_prediv, cpu_postdiv; int dsp_base, dsp_mul, dsp_prediv, dsp_postdiv; int usb_base, usb_mul, usb_prediv, usb_postdiv; @@ -371,79 +377,94 @@ static void __init tnetd7200_init_clocks(void) Clocks: Async mode Clocks: Setting DSP clock Clocks: prediv: 1, postdiv: 1, mul: 5 - Clocks: base = 25000000, frequency = 125000000, prediv = 1, postdiv = 2, postdiv2 = 1, mul = 10 + Clocks: base = 25000000, frequency = 125000000, prediv = 1, + postdiv = 2, postdiv2 = 1, mul = 10 Clocks: Setting CPU clock Adjusted requested frequency 211000000 to 211968000 Clocks: prediv: 1, postdiv: 1, mul: 6 - Clocks: base = 35328000, frequency = 211968000, prediv = 1, postdiv = 1, postdiv2 = -1, mul = 6 + Clocks: base = 35328000, frequency = 211968000, prediv = 1, + postdiv = 1, postdiv2 = -1, mul = 6 Clocks: Setting USB clock Adjusted requested frequency 48000000 to 48076920 Clocks: prediv: 13, postdiv: 1, mul: 5 - Clocks: base = 125000000, frequency = 48000000, prediv = 13, postdiv = 1, postdiv2 = -1, mul = 5 + Clocks: base = 125000000, frequency = 48000000, prediv = 13, + postdiv = 1, postdiv2 = -1, mul = 5 - DSL didn't work if you didn't set the postdiv 2:1 postdiv2 combination, driver hung on startup. - Haven't tested this on a synchronous board, neither do i know what to do with ar7_dsp_clock + DSL didn't work if you didn't set the postdiv 2:1 postdiv2 combination, + driver hung on startup. + Haven't tested this on a synchronous board, + neither do i know what to do with ar7_dsp_clock */ cpu_base = tnetd7200_get_clock_base(TNETD7200_CLOCK_ID_CPU, bootcr); dsp_base = tnetd7200_get_clock_base(TNETD7200_CLOCK_ID_DSP, bootcr); if (*bootcr & BOOT_PLL_ASYNC_MODE) { - printk("Clocks: Async mode\n"); - - printk("Clocks: Setting DSP clock\n"); - calculate(dsp_base, TNETD7200_DEF_DSP_CLK, &dsp_prediv, &dsp_postdiv, &dsp_mul); - ar7_bus_clock = ((dsp_base / dsp_prediv) * dsp_mul) / dsp_postdiv; - tnetd7200_set_clock(dsp_base, &clocks->dsp, - dsp_prediv, dsp_postdiv * 2, dsp_postdiv, dsp_mul * 2, + printk(KERN_INFO "Clocks: Async mode\n"); + + printk(KERN_INFO "Clocks: Setting DSP clock\n"); + calculate(dsp_base, TNETD7200_DEF_DSP_CLK, + &dsp_prediv, &dsp_postdiv, &dsp_mul); + ar7_bus_clock = + ((dsp_base / dsp_prediv) * dsp_mul) / dsp_postdiv; + tnetd7200_set_clock(dsp_base, &clocks->dsp, + dsp_prediv, dsp_postdiv * 2, dsp_postdiv, dsp_mul * 2, ar7_bus_clock); - printk("Clocks: Setting CPU clock\n"); - calculate(cpu_base, TNETD7200_DEF_CPU_CLK, &cpu_prediv, &cpu_postdiv, &cpu_mul); - ar7_cpu_clock = ((cpu_base / cpu_prediv) * cpu_mul) / cpu_postdiv; - tnetd7200_set_clock(cpu_base, &clocks->cpu, - cpu_prediv, cpu_postdiv, -1, cpu_mul, + printk(KERN_INFO "Clocks: Setting CPU clock\n"); + calculate(cpu_base, TNETD7200_DEF_CPU_CLK, &cpu_prediv, + &cpu_postdiv, &cpu_mul); + ar7_cpu_clock = + ((cpu_base / cpu_prediv) * cpu_mul) / cpu_postdiv; + tnetd7200_set_clock(cpu_base, &clocks->cpu, + cpu_prediv, cpu_postdiv, -1, cpu_mul, ar7_cpu_clock); } else { if (*bootcr & BOOT_PLL_2TO1_MODE) { - printk("Clocks: Sync 2:1 mode\n"); - - printk("Clocks: Setting CPU clock\n"); - calculate(cpu_base, TNETD7200_DEF_CPU_CLK, &cpu_prediv, &cpu_postdiv, &cpu_mul); - ar7_cpu_clock = ((cpu_base / cpu_prediv) * cpu_mul) / cpu_postdiv; - tnetd7200_set_clock(cpu_base, &clocks->cpu, - cpu_prediv, cpu_postdiv, -1, cpu_mul, + printk(KERN_INFO "Clocks: Sync 2:1 mode\n"); + + printk(KERN_INFO "Clocks: Setting CPU clock\n"); + calculate(cpu_base, TNETD7200_DEF_CPU_CLK, &cpu_prediv, + &cpu_postdiv, &cpu_mul); + ar7_cpu_clock = ((cpu_base / cpu_prediv) * cpu_mul) + / cpu_postdiv; + tnetd7200_set_clock(cpu_base, &clocks->cpu, + cpu_prediv, cpu_postdiv, -1, cpu_mul, ar7_cpu_clock); - printk("Clocks: Setting DSP clock\n"); - calculate(dsp_base, TNETD7200_DEF_DSP_CLK, &dsp_prediv, &dsp_postdiv, &dsp_mul); + printk(KERN_INFO "Clocks: Setting DSP clock\n"); + calculate(dsp_base, TNETD7200_DEF_DSP_CLK, &dsp_prediv, + &dsp_postdiv, &dsp_mul); ar7_bus_clock = ar7_cpu_clock / 2; - tnetd7200_set_clock(dsp_base, &clocks->dsp, - dsp_prediv, dsp_postdiv * 2, dsp_postdiv, dsp_mul * 2, - ar7_bus_clock); + tnetd7200_set_clock(dsp_base, &clocks->dsp, + dsp_prediv, dsp_postdiv * 2, dsp_postdiv, + dsp_mul * 2, ar7_bus_clock); } else { - printk("Clocks: Sync 1:1 mode\n"); + printk(KERN_INFO "Clocks: Sync 1:1 mode\n"); - printk("Clocks: Setting DSP clock\n"); - calculate(dsp_base, TNETD7200_DEF_CPU_CLK, &dsp_prediv, &dsp_postdiv, &dsp_mul); - ar7_bus_clock = ((dsp_base / dsp_prediv) * dsp_mul) / dsp_postdiv; - tnetd7200_set_clock(dsp_base, &clocks->dsp, - dsp_prediv, dsp_postdiv * 2, dsp_postdiv, dsp_mul * 2, - ar7_bus_clock); + printk(KERN_INFO "Clocks: Setting DSP clock\n"); + calculate(dsp_base, TNETD7200_DEF_CPU_CLK, &dsp_prediv, + &dsp_postdiv, &dsp_mul); + ar7_bus_clock = ((dsp_base / dsp_prediv) * dsp_mul) + / dsp_postdiv; + tnetd7200_set_clock(dsp_base, &clocks->dsp, + dsp_prediv, dsp_postdiv * 2, dsp_postdiv, + dsp_mul * 2, ar7_bus_clock); ar7_cpu_clock = ar7_bus_clock; } } - printk("Clocks: Setting USB clock\n"); + printk(KERN_INFO "Clocks: Setting USB clock\n"); usb_base = ar7_bus_clock; - calculate(usb_base, TNETD7200_DEF_USB_CLK, &usb_prediv, &usb_postdiv, &usb_mul); - tnetd7200_set_clock(usb_base, &clocks->usb, - usb_prediv, usb_postdiv, -1, usb_mul, + calculate(usb_base, TNETD7200_DEF_USB_CLK, &usb_prediv, + &usb_postdiv, &usb_mul); + tnetd7200_set_clock(usb_base, &clocks->usb, + usb_prediv, usb_postdiv, -1, usb_mul, TNETD7200_DEF_USB_CLK); - #warning FIXME: ????! Hrmm + #warning FIXME ar7_dsp_clock = ar7_cpu_clock; iounmap(clocks); diff --git a/target/linux/ar7/files/arch/mips/ar7/gpio.c b/target/linux/ar7/files/arch/mips/ar7/gpio.c index 836cea1ac..e18dfe873 100644 --- a/target/linux/ar7/files/arch/mips/ar7/gpio.c +++ b/target/linux/ar7/files/arch/mips/ar7/gpio.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2007 OpenWrt.org * * This program is free software; you can redistribute it and/or modify diff --git a/target/linux/ar7/files/arch/mips/ar7/irq.c b/target/linux/ar7/files/arch/mips/ar7/irq.c index 44cce5c40..074a51c18 100644 --- a/target/linux/ar7/files/arch/mips/ar7/irq.c +++ b/target/linux/ar7/files/arch/mips/ar7/irq.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2006, 2007 OpenWrt.org * * This program is free software; you can redistribute it and/or modify @@ -25,23 +23,23 @@ #include <asm/mipsregs.h> #include <asm/ar7/ar7.h> -#define EXCEPT_OFFSET 0x80 -#define PACE_OFFSET 0xA0 -#define CHNLS_OFFSET 0x200 - -#define REG_OFFSET(irq, reg) ((irq) / 32 * 0x4 + reg * 0x10) -#define SEC_REG_OFFSET(reg) (EXCEPT_OFFSET + reg * 0x8) -#define SEC_SR_OFFSET (SEC_REG_OFFSET(0)) /* 0x80 */ -#define CR_OFFSET(irq) (REG_OFFSET(irq, 1)) /* 0x10 */ -#define SEC_CR_OFFSET (SEC_REG_OFFSET(1)) /* 0x88 */ -#define ESR_OFFSET(irq) (REG_OFFSET(irq, 2)) /* 0x20 */ -#define SEC_ESR_OFFSET (SEC_REG_OFFSET(2)) /* 0x90 */ -#define ECR_OFFSET(irq) (REG_OFFSET(irq, 3)) /* 0x30 */ -#define SEC_ECR_OFFSET (SEC_REG_OFFSET(3)) /* 0x98 */ -#define PIR_OFFSET (0x40) -#define MSR_OFFSET (0x44) -#define PM_OFFSET(irq) (REG_OFFSET(irq, 5)) /* 0x50 */ -#define TM_OFFSET(irq) (REG_OFFSET(irq, 6)) /* 0x60 */ +#define EXCEPT_OFFSET 0x80 +#define PACE_OFFSET 0xA0 +#define CHNLS_OFFSET 0x200 + +#define REG_OFFSET(irq, reg) ((irq) / 32 * 0x4 + reg * 0x10) +#define SEC_REG_OFFSET(reg) (EXCEPT_OFFSET + reg * 0x8) +#define SEC_SR_OFFSET (SEC_REG_OFFSET(0)) /* 0x80 */ +#define CR_OFFSET(irq) (REG_OFFSET(irq, 1)) /* 0x10 */ +#define SEC_CR_OFFSET (SEC_REG_OFFSET(1)) /* 0x88 */ +#define ESR_OFFSET(irq) (REG_OFFSET(irq, 2)) /* 0x20 */ +#define SEC_ESR_OFFSET (SEC_REG_OFFSET(2)) /* 0x90 */ +#define ECR_OFFSET(irq) (REG_OFFSET(irq, 3)) /* 0x30 */ +#define SEC_ECR_OFFSET (SEC_REG_OFFSET(3)) /* 0x98 */ +#define PIR_OFFSET (0x40) +#define MSR_OFFSET (0x44) +#define PM_OFFSET(irq) (REG_OFFSET(irq, 5)) /* 0x50 */ +#define TM_OFFSET(irq) (REG_OFFSET(irq, 6)) /* 0x60 */ #define REG(addr) ((u32 *)(KSEG1ADDR(AR7_REGS_IRQ) + addr)) @@ -73,6 +71,7 @@ static struct irq_chip ar7_sec_irq_type = { static struct irqaction ar7_cascade_action = { .handler = no_action, + .name = "AR7 cascade interrupt" }; diff --git a/target/linux/ar7/files/arch/mips/ar7/memory.c b/target/linux/ar7/files/arch/mips/ar7/memory.c index 4c930c08c..65a094cc3 100644 --- a/target/linux/ar7/files/arch/mips/ar7/memory.c +++ b/target/linux/ar7/files/arch/mips/ar7/memory.c @@ -1,24 +1,22 @@ /* - * $Id$ - * * Copyright (C) 2007 OpenWrt.org - * + * * Based on arch/mips/mm/init.c * Copyright (C) 1994 - 2000 Ralf Baechle * Copyright (C) 1999, 2000 Silicon Graphics, Inc. * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved. - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/target/linux/ar7/files/arch/mips/ar7/platform.c b/target/linux/ar7/files/arch/mips/ar7/platform.c index b1122a6b7..cbbe773cd 100644 --- a/target/linux/ar7/files/arch/mips/ar7/platform.c +++ b/target/linux/ar7/files/arch/mips/ar7/platform.c @@ -1,18 +1,16 @@ /* - * $Id$ - * * Copyright (C) 2006, 2007 OpenWrt.org - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -28,8 +26,9 @@ #include <linux/serial.h> #include <linux/serial_8250.h> #include <linux/ioport.h> +#include <linux/io.h> + #include <asm/addrspace.h> -#include <asm/io.h> #include <asm/ar7/ar7.h> #include <asm/ar7/gpio.h> #include <asm/ar7/prom.h> @@ -91,7 +90,7 @@ static struct resource physmap_flash_resource = { .flags = IORESOURCE_MEM, .start = 0x10000000, .end = 0x107fffff, -}; +}; static struct resource cpmac_low_res[] = { { @@ -253,8 +252,7 @@ static struct platform_device vlynq_high = { */ #if !defined(CONFIG_SERIAL_8250) -static struct plat_serial8250_port uart0_data = -{ +static struct plat_serial8250_port uart0_data = { .mapbase = AR7_REGS_UART0, .irq = AR7_IRQ_UART0, .regshift = 2, @@ -262,8 +260,7 @@ static struct plat_serial8250_port uart0_data = .flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, }; -static struct plat_serial8250_port uart1_data = -{ +static struct plat_serial8250_port uart1_data = { .mapbase = UR8_REGS_UART1, .irq = AR7_IRQ_UART1, .regshift = 2, @@ -346,7 +343,7 @@ static int __init ar7_register_devices(void) return res; - // Only TNETD73xx have a second serial port + /* Only TNETD73xx have a second serial port */ if (ar7_has_second_uart()) { uart_port[1].type = PORT_AR7; uart_port[1].line = 1; @@ -361,21 +358,20 @@ static int __init ar7_register_devices(void) return res; } -#else // !CONFIG_SERIAL_8250 +#else /* !CONFIG_SERIAL_8250 */ uart_data[0].uartclk = ar7_bus_freq() / 2; uart_data[1].uartclk = uart_data[0].uartclk; - // Only TNETD73xx have a second serial port - if (ar7_has_second_uart()) { + /* Only TNETD73xx have a second serial port */ + if (ar7_has_second_uart()) uart.dev.platform_data = uart_data; - } res = platform_device_register(&uart); if (res) return res; -#endif // CONFIG_SERIAL_8250 +#endif /* CONFIG_SERIAL_8250 */ res = platform_device_register(&physmap_flash); if (res) diff --git a/target/linux/ar7/files/arch/mips/ar7/prom.c b/target/linux/ar7/files/arch/mips/ar7/prom.c index e06cd32a4..a560c551c 100644 --- a/target/linux/ar7/files/arch/mips/ar7/prom.c +++ b/target/linux/ar7/files/arch/mips/ar7/prom.c @@ -1,8 +1,6 @@ /* - * $Id$ - * * Copyright (C) 2006, 2007 OpenWrt.org - * + * * Carsten Langgaard, carstenl@mips.com * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved. * @@ -27,9 +25,8 @@ #include <linux/spinlock.h> #include <linux/module.h> #include <linux/string.h> -#include <asm/io.h> +#include <linux/io.h> #include <asm/bootinfo.h> -#include <asm/mips-boards/prom.h> #include <asm/gdb-stub.h> #include <asm/ar7/ar7.h> @@ -44,7 +41,7 @@ struct env_var { static struct env_var adam2_env[MAX_ENTRY] = { { 0, }, }; -char * prom_getenv(char *name) +char *prom_getenv(char *name) { int i; for (i = 0; (i < MAX_ENTRY) && adam2_env[i].name; i++) @@ -53,6 +50,7 @@ char * prom_getenv(char *name) return NULL; } +EXPORT_SYMBOL(prom_getenv); char * __init prom_getcmdline(void) { @@ -67,8 +65,8 @@ static void __init ar7_init_cmdline(int argc, char *argv[]) actr = 1; /* Always ignore argv[0] */ cp = &(arcs_cmdline[0]); - while(actr < argc) { - strcpy(cp, argv[actr]); + while (actr < argc) { + strcpy(cp, argv[actr]); cp += strlen(argv[actr]); *cp++ = ' '; actr++; @@ -119,23 +117,23 @@ static struct psp_var_map_entry psp_var_map[] = { Well-known variable (num is looked up in table above for matching variable name) Example: cpufrequency=211968000 -+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ -| 01 |CTRL|CHECKSUM | 01 | _2 | _1 | _1 | _9 | _6 | _8 | _0 | _0 | _0 | \0 | FF | -+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ ++----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+--- +| 01 |CTRL|CHECKSUM | 01 | _2 | _1 | _1 | _9 | _6 | _8 | _0 | _0 | _0 | \0 | FF ++----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+--- Name=Value pair in a single chunk Example: NAME=VALUE -+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ -| 00 |CTRL|CHECKSUM | 01 | _N | _A | _M | _E | _0 | _V | _A | _L | _U | _E | \0 | -+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ ++----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+--- +| 00 |CTRL|CHECKSUM | 01 | _N | _A | _M | _E | _0 | _V | _A | _L | _U | _E | \0 ++----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+--- Name=Value pair in 2 chunks (len is the number of chunks) Example: bootloaderVersion=1.3.7.15 -+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ -| 00 |CTRL|CHECKSUM | 02 | _b | _o | _o | _t | _l | _o | _a | _d | _e | _r | _V | -+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ -| _e | _r | _s | _i | _o | _n | \0 | _1 | _. | _3 | _. | _7 | _. | _1 | _5 | \0 | -+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+ ++----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+--- +| 00 |CTRL|CHECKSUM | 02 | _b | _o | _o | _t | _l | _o | _a | _d | _e | _r | _V ++----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+--- +| _e | _r | _s | _i | _o | _n | \0 | _1 | _. | _3 | _. | _7 | _. | _1 | _5 | \0 ++----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+--- Data is padded with 0xFF @@ -152,7 +150,7 @@ static char * __init lookup_psp_var_map(u8 num) for (i = 0; i < sizeof(psp_var_map); i++) if (psp_var_map[i].num == num) return psp_var_map[i].value; - + return NULL; } @@ -204,7 +202,7 @@ static void __init ar7_init_env(struct env_var *env) struct psbl_rec *psbl = (struct psbl_rec *)(KSEG1ADDR(0x14000300)); void *psp_env = (void *)KSEG1ADDR(psbl->env_base); - if(strcmp(psp_env, psp_env_version) == 0) { + if (strcmp(psp_env, psp_env_version) == 0) { parse_psp_env(psp_env); } else { for (i = 0; i < MAX_ENTRY; i++, env++) @@ -289,20 +287,20 @@ int prom_putchar(char c) return 1; } -// from adm5120/prom.c +/* from adm5120/prom.c */ void prom_printf(char *fmt, ...) { va_list args; int l; char *p, *buf_end; char buf[1024]; - + va_start(args, fmt); l = vsprintf(buf, fmt, args); /* hopefully i < sizeof(buf) */ va_end(args); - + buf_end = buf + l; - + for (p = buf; p < buf_end; p++) { /* Crude cr/nl handling is better than none */ if (*p == '\n') @@ -319,8 +317,6 @@ int putDebugChar(char c) char getDebugChar(void) { - return prom_getchar(); + return prom_getchar(); } #endif - -EXPORT_SYMBOL(prom_getenv); diff --git a/target/linux/ar7/files/arch/mips/ar7/setup.c b/target/linux/ar7/files/arch/mips/ar7/setup.c index 8ac757777..388557ff0 100644 --- a/target/linux/ar7/files/arch/mips/ar7/setup.c +++ b/target/linux/ar7/files/arch/mips/ar7/setup.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * Copyright (C) 2006, 2007 OpenWrt.org * * Carsten Langgaard, carstenl@mips.com @@ -102,7 +100,8 @@ void __init plat_mem_setup(void) iomem_resource.start = 0; iomem_resource.end = ~0; - printk("%s, ID: 0x%04x, Revision: 0x%02x\n", get_system_type(), + printk(KERN_INFO "%s, ID: 0x%04x, Revision: 0x%02x\n", + get_system_type(), ar7_chip_id(), ar7_chip_rev()); } diff --git a/target/linux/ar7/files/arch/mips/ar7/time.c b/target/linux/ar7/files/arch/mips/ar7/time.c index 6a1ee7a4d..6a32bf63e 100644 --- a/target/linux/ar7/files/arch/mips/ar7/time.c +++ b/target/linux/ar7/files/arch/mips/ar7/time.c @@ -1,8 +1,6 @@ /* - * $Id$ - * * Copyright (C) 2006, 2007 OpenWrt.org - * + * * Carsten Langgaard, carstenl@mips.com * Copyright (C) 1999,2000 MIPS Technologies, Inc. All rights reserved. * @@ -22,30 +20,7 @@ * Setting up the clock on the MIPS boards. */ -#include <linux/types.h> -#include <linux/init.h> -#include <linux/kernel_stat.h> -#include <linux/sched.h> -#include <linux/spinlock.h> -#include <linux/interrupt.h> -#include <linux/time.h> -#include <linux/timex.h> -#include <linux/mc146818rtc.h> - -#include <asm/mipsregs.h> -#include <asm/ptrace.h> -#include <asm/hardirq.h> -#include <asm/irq.h> -#include <asm/div64.h> -#include <asm/cpu.h> #include <asm/time.h> -#include <asm/mc146818-time.h> -#include <asm/msc01_ic.h> - -#include <asm/mips-boards/generic.h> -#include <asm/mips-boards/prom.h> -#include <asm/mips-boards/maltaint.h> -#include <asm/mc146818-time.h> #include <asm/ar7/ar7.h> void __init ar7_time_init(void) diff --git a/target/linux/ar7/files/arch/mips/ar7/vlynq-pci.c b/target/linux/ar7/files/arch/mips/ar7/vlynq-pci.c index e340cdda3..9f3b63d69 100644 --- a/target/linux/ar7/files/arch/mips/ar7/vlynq-pci.c +++ b/target/linux/ar7/files/arch/mips/ar7/vlynq-pci.c @@ -1,18 +1,16 @@ /* - * $Id$ - * * Copyright (C) 2006, 2007 OpenWrt.org - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/target/linux/ar7/files/arch/mips/ar7/vlynq.c b/target/linux/ar7/files/arch/mips/ar7/vlynq.c index 27d4ec123..60ab3dd62 100644 --- a/target/linux/ar7/files/arch/mips/ar7/vlynq.c +++ b/target/linux/ar7/files/arch/mips/ar7/vlynq.c @@ -1,18 +1,16 @@ /* - * $Id$ - * * Copyright (C) 2006, 2007 OpenWrt.org - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -30,8 +28,9 @@ #include <linux/irq.h> #include <linux/interrupt.h> #include <linux/device.h> +#include <linux/io.h> + #include <asm/addrspace.h> -#include <asm/io.h> #include <asm/ar7/ar7.h> #include <asm/ar7/vlynq.h> @@ -81,10 +80,13 @@ struct vlynq_regs { static void vlynq_dump_regs(struct vlynq_device *dev) { int i; - printk("VLYNQ local=%p remote=%p\n", dev->local, dev->remote); + printk(KERN_DEBUG "VLYNQ local=%p remote=%p\n", + dev->local, dev->remote); for (i = 0; i < 32; i++) { - printk("VLYNQ: local %d: %08x\n", i + 1, ((u32 *)dev->local)[i]); - printk("VLYNQ: remote %d: %08x\n", i + 1, ((u32 *)dev->remote)[i]); + printk(KERN_DEBUG "VLYNQ: local %d: %08x\n", + i + 1, ((u32 *)dev->local)[i]); + printk(KERN_DEBUG "VLYNQ: remote %d: %08x\n", + i + 1, ((u32 *)dev->remote)[i]); } } @@ -92,10 +94,10 @@ static void vlynq_dump_mem(u32 *base, int count) { int i; for (i = 0; i < (count + 3) / 4; i++) { - if (i % 4 == 0) printk("\nMEM[0x%04x]:", i * 4); - printk(" 0x%08x", *(base + i)); + if (i % 4 == 0) printk(KERN_DEBUG "\nMEM[0x%04x]:", i * 4); + printk(KERN_DEBUG " 0x%08x", *(base + i)); } - printk("\n"); + printk(KERN_DEBUG "\n"); } #endif @@ -212,8 +214,9 @@ static int vlynq_setup_irq(struct vlynq_device *dev) int i; if (dev->local_irq == dev->remote_irq) { - printk("%s: local vlynq irq should be different from remote\n", - dev->dev.bus_id); + printk(KERN_WARNING + "%s: local vlynq irq should be different from remote\n", + dev->dev.bus_id); return -EINVAL; } @@ -239,7 +242,7 @@ static int vlynq_setup_irq(struct vlynq_device *dev) } if (request_irq(dev->irq, vlynq_irq, SA_SHIRQ, "vlynq", dev)) { - printk("%s: request_irq failed\n", dev->dev.bus_id); + printk(KERN_ERR "%s: request_irq failed\n", dev->dev.bus_id); return -EAGAIN; } @@ -363,7 +366,7 @@ void vlynq_set_remote_mapping(struct vlynq_device *dev, u32 tx_offset, int vlynq_virq_to_irq(struct vlynq_device *dev, int virq) { - if ((virq < 0) || (virq >= PER_DEVICE_IRQS)) + if ((virq < 0) || (virq >= PER_DEVICE_IRQS)) return -EINVAL; if ((virq == dev->local_irq) || (virq == dev->remote_irq)) @@ -374,7 +377,7 @@ int vlynq_virq_to_irq(struct vlynq_device *dev, int virq) int vlynq_irq_to_virq(struct vlynq_device *dev, int irq) { - if ((irq < dev->irq_start) || (irq >= dev->irq_start + PER_DEVICE_IRQS)) + if ((irq < dev->irq_start) || (irq >= dev->irq_start + PER_DEVICE_IRQS)) return -EINVAL; return irq - dev->irq_start; @@ -382,7 +385,7 @@ int vlynq_irq_to_virq(struct vlynq_device *dev, int irq) int vlynq_set_local_irq(struct vlynq_device *dev, int virq) { - if ((virq < 0) || (virq >= PER_DEVICE_IRQS)) + if ((virq < 0) || (virq >= PER_DEVICE_IRQS)) return -EINVAL; if (virq == dev->remote_irq) @@ -395,7 +398,7 @@ int vlynq_set_local_irq(struct vlynq_device *dev, int virq) int vlynq_set_remote_irq(struct vlynq_device *dev, int virq) { - if ((virq < 0) || (virq >= PER_DEVICE_IRQS)) + if ((virq < 0) || (virq >= PER_DEVICE_IRQS)) return -EINVAL; if (virq == dev->local_irq) @@ -450,14 +453,16 @@ static int vlynq_probe(struct platform_device *pdev) len = regs_res->end - regs_res->start; if (!request_mem_region(regs_res->start, len, dev->dev.bus_id)) { - printk("%s: Can't request vlynq registers\n", dev->dev.bus_id); + printk(KERN_ERR "%s: Can't request vlynq registers\n", + dev->dev.bus_id); result = -ENXIO; goto fail_request; } dev->local = ioremap_nocache(regs_res->start, len); if (!dev->local) { - printk("%s: Can't remap vlynq registers\n", dev->dev.bus_id); + printk(KERN_ERR "%s: Can't remap vlynq registers\n", + dev->dev.bus_id); result = -ENXIO; goto fail_remap; } @@ -474,7 +479,7 @@ static int vlynq_probe(struct platform_device *pdev) goto fail_register; platform_set_drvdata(pdev, dev); - printk("%s: regs 0x%p, irq %d, mem 0x%p\n", + printk(KERN_INFO "%s: regs 0x%p, irq %d, mem 0x%p\n", dev->dev.bus_id, (void *)dev->regs_start, dev->irq, (void *)dev->mem_start); diff --git a/target/linux/ar7/files/drivers/char/ar7_gpio.c b/target/linux/ar7/files/drivers/char/ar7_gpio.c index a5245da35..c0ee897e2 100644 --- a/target/linux/ar7/files/drivers/char/ar7_gpio.c +++ b/target/linux/ar7/files/drivers/char/ar7_gpio.c @@ -25,9 +25,8 @@ #include <linux/kernel.h> #include <linux/init.h> #include <linux/platform_device.h> -#include <asm/uaccess.h> -#include <asm/io.h> - +#include <linux/uaccess.h> +#include <linux/io.h> #include <linux/types.h> #include <linux/cdev.h> #include <gpio.h> @@ -39,7 +38,7 @@ MODULE_AUTHOR("Nicolas Thill <nico@openwrt.org>"); MODULE_DESCRIPTION(LONGNAME); MODULE_LICENSE("GPL"); -static int ar7_gpio_major = 0; +static int ar7_gpio_major; static ssize_t ar7_gpio_write(struct file *file, const char __user *buf, size_t len, loff_t *ppos) @@ -84,8 +83,8 @@ static ssize_t ar7_gpio_write(struct file *file, const char __user *buf, return len; } -static ssize_t ar7_gpio_read(struct file *file, char __user * buf, - size_t len, loff_t * ppos) +static ssize_t ar7_gpio_read(struct file *file, char __user *buf, + size_t len, loff_t *ppos) { int pin = iminor(file->f_dentry->d_inode); int value; diff --git a/target/linux/ar7/files/drivers/char/watchdog/ar7_wdt.c b/target/linux/ar7/files/drivers/char/watchdog/ar7_wdt.c index 271025008..04c2e2e94 100644 --- a/target/linux/ar7/files/drivers/char/watchdog/ar7_wdt.c +++ b/target/linux/ar7/files/drivers/char/watchdog/ar7_wdt.c @@ -33,11 +33,10 @@ #include <linux/reboot.h> #include <linux/fs.h> #include <linux/ioport.h> +#include <linux/io.h> +#include <linux/uaccess.h> #include <asm/addrspace.h> -#include <asm/io.h> -#include <asm/uaccess.h> - #include <asm/ar7/ar7.h> #define DRVNAME "ar7_wdt" @@ -56,7 +55,7 @@ static int nowayout = WATCHDOG_NOWAYOUT; module_param(nowayout, int, 0); MODULE_PARM_DESC(nowayout, "Disable watchdog shutdown on close"); -typedef struct { +struct ar7_wdt { u32 kick_lock; u32 kick; u32 change_lock; @@ -65,7 +64,7 @@ typedef struct { u32 disable; u32 prescale_lock; u32 prescale; -} ar7_wdt_t; +}; static struct semaphore open_semaphore; static unsigned expect_close; @@ -73,15 +72,14 @@ static unsigned expect_close; /* XXX currently fixed, allows max margin ~68.72 secs */ #define prescale_value 0xffff -// Offset of the WDT registers +/* Offset of the WDT registers */ static unsigned long ar7_regs_wdt; -// Pointer to the remapped WDT IO space -static ar7_wdt_t *ar7_wdt; +/* Pointer to the remapped WDT IO space */ +static struct ar7_wdt *ar7_wdt; static void ar7_wdt_get_regs(void) { u16 chip_id = ar7_chip_id(); - switch (chip_id) - { + switch (chip_id) { case AR7_CHIP_7100: case AR7_CHIP_7200: ar7_regs_wdt = AR7_REGS_WDT; @@ -92,6 +90,7 @@ static void ar7_wdt_get_regs(void) } } + static void ar7_wdt_kick(u32 value) { ar7_wdt->kick_lock = 0x5555; @@ -188,7 +187,9 @@ static int ar7_wdt_open(struct inode *inode, struct file *file) static int ar7_wdt_release(struct inode *inode, struct file *file) { if (!expect_close) { - printk(KERN_WARNING DRVNAME ": watchdog device closed unexpectedly, will not disable the watchdog timer\n"); + printk(KERN_WARNING DRVNAME + ": watchdog device closed unexpectedly," + "will not disable the watchdog timer\n"); } else if (!nowayout) { ar7_wdt_disable_wdt(); } @@ -197,8 +198,8 @@ static int ar7_wdt_release(struct inode *inode, struct file *file) return 0; } -static int ar7_wdt_notify_sys(struct notifier_block *this, - unsigned long code, void *unused) +static int ar7_wdt_notify_sys(struct notifier_block *this, + unsigned long code, void *unused) { if (code == SYS_HALT || code == SYS_POWER_OFF) if (!nowayout) @@ -207,13 +208,12 @@ static int ar7_wdt_notify_sys(struct notifier_block *this, return NOTIFY_DONE; } -static struct notifier_block ar7_wdt_notifier = -{ +static struct notifier_block ar7_wdt_notifier = { .notifier_call = ar7_wdt_notify_sys }; -static ssize_t ar7_wdt_write(struct file *file, const char *data, - size_t len, loff_t *ppos) +static ssize_t ar7_wdt_write(struct file *file, const char *data, + size_t len, loff_t *ppos) { if (ppos != &file->f_pos) return -ESPIPE; @@ -237,19 +237,21 @@ static ssize_t ar7_wdt_write(struct file *file, const char *data, return len; } -static int ar7_wdt_ioctl(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) +static int ar7_wdt_ioctl(struct inode *inode, struct file *file, + unsigned int cmd, unsigned long arg) { static struct watchdog_info ident = { .identity = LONGNAME, - .firmware_version = 1, + .firmware_version = 1, .options = (WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING), }; int new_margin; - + switch (cmd) { + default: + return -ENOTTY; case WDIOC_GETSUPPORT: - if(copy_to_user((struct watchdog_info *)arg, &ident, + if (copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident))) return -EFAULT; return 0; @@ -274,8 +276,6 @@ static int ar7_wdt_ioctl(struct inode *inode, struct file *file, if (put_user(margin, (int *)arg)) return -EFAULT; return 0; - default: - return -ENOTTY; } } @@ -297,14 +297,16 @@ static int __init ar7_wdt_init(void) { int rc; - ar7_wdt_get_regs(); + ar7_wdt_get_regs(); - if (!request_mem_region(ar7_regs_wdt, sizeof(ar7_wdt_t), LONGNAME)) { + if (!request_mem_region(ar7_regs_wdt, sizeof(struct ar7_wdt), + LONGNAME)) { printk(KERN_WARNING DRVNAME ": watchdog I/O region busy\n"); return -EBUSY; } - ar7_wdt = (ar7_wdt_t *)ioremap(ar7_regs_wdt, sizeof(ar7_wdt_t)); + ar7_wdt = (struct ar7_wdt *) + ioremap(ar7_regs_wdt, sizeof(struct ar7_wdt)); ar7_wdt_disable_wdt(); ar7_wdt_prescale(prescale_value); @@ -320,7 +322,8 @@ static int __init ar7_wdt_init(void) rc = register_reboot_notifier(&ar7_wdt_notifier); if (rc) { - printk(KERN_ERR DRVNAME ": unable to register reboot notifier\n"); + printk(KERN_ERR DRVNAME + ": unable to register reboot notifier\n"); goto out_register; } goto out; @@ -328,7 +331,7 @@ static int __init ar7_wdt_init(void) out_register: misc_deregister(&ar7_wdt_miscdev); out_alloc: - release_mem_region(ar7_regs_wdt, sizeof(ar7_wdt_t)); + release_mem_region(ar7_regs_wdt, sizeof(struct ar7_wdt)); out: return rc; } @@ -338,7 +341,7 @@ static void __exit ar7_wdt_cleanup(void) unregister_reboot_notifier(&ar7_wdt_notifier); misc_deregister(&ar7_wdt_miscdev); iounmap(ar7_wdt); - release_mem_region(ar7_regs_wdt, sizeof(ar7_wdt_t)); + release_mem_region(ar7_regs_wdt, sizeof(struct ar7_wdt)); } module_init(ar7_wdt_init); diff --git a/target/linux/ar7/files/drivers/leds/leds-ar7.c b/target/linux/ar7/files/drivers/leds/leds-ar7.c index 85533dee1..809a4d444 100644 --- a/target/linux/ar7/files/drivers/leds/leds-ar7.c +++ b/target/linux/ar7/files/drivers/leds/leds-ar7.c @@ -24,7 +24,7 @@ #include <linux/platform_device.h> #include <linux/leds.h> #include <linux/err.h> -#include <asm/io.h> +#include <linux/io.h> #include <gpio.h> #define DRVNAME "ar7-leds" @@ -35,7 +35,7 @@ MODULE_AUTHOR("Nicolas Thill <nico@openwrt.org>"); MODULE_DESCRIPTION(LONGNAME); MODULE_LICENSE("GPL"); -static void ar7_status_led_set(struct led_classdev *pled, +static void ar7_status_led_set(struct led_classdev *pled, enum led_brightness value) { gpio_set_value(AR7_GPIO_BIT_STATUS_LED, value ? 0 : 1); @@ -69,7 +69,7 @@ static int ar7_leds_probe(struct platform_device *pdev) int rc; rc = led_classdev_register(&pdev->dev, &ar7_status_led); - if (rc < 0 ) + if (rc < 0) goto out; ar7_gpio_enable(AR7_GPIO_BIT_STATUS_LED); diff --git a/target/linux/ar7/files/drivers/mtd/ar7part.c b/target/linux/ar7/files/drivers/mtd/ar7part.c index 111157523..b8c0ed0b2 100644 --- a/target/linux/ar7/files/drivers/mtd/ar7part.c +++ b/target/linux/ar7/files/drivers/mtd/ar7part.c @@ -36,8 +36,8 @@ struct ar7_bin_rec { static struct mtd_partition ar7_parts[5]; -static int create_mtd_partitions(struct mtd_info *master, - struct mtd_partition **pparts, +static int create_mtd_partitions(struct mtd_info *master, + struct mtd_partition **pparts, unsigned long origin) { struct ar7_bin_rec header; @@ -61,7 +61,8 @@ static int create_mtd_partitions(struct mtd_info *master, do { offset = pre_size; - master->read(master, offset, sizeof(header), &len, (u_char *)&header); + master->read(master, offset, + sizeof(header), &len, (u_char *)&header); if (!strncmp((char *)&header, "TIENV0.8", 8)) ar7_parts[1].offset = pre_size; if (header.checksum == 0xfeedfa42) @@ -83,7 +84,7 @@ static int create_mtd_partitions(struct mtd_info *master, while (header.length) { offset += sizeof(header) + header.length; master->read(master, offset, sizeof(header), - &len, (u_char *)&header); + &len, (u_char *)&header); } root_offset = offset + sizeof(header) + 4; break; @@ -91,7 +92,7 @@ static int create_mtd_partitions(struct mtd_info *master, while (header.length) { offset += sizeof(header) + header.length; master->read(master, offset, sizeof(header), - &len, (u_char *)&header); + &len, (u_char *)&header); } root_offset = offset + sizeof(header) + 4 + 0xff; root_offset &= ~(u32)0xff; @@ -101,7 +102,8 @@ static int create_mtd_partitions(struct mtd_info *master, break; } - master->read(master, root_offset, sizeof(header), &len, (u_char *)&header); + master->read(master, root_offset, + sizeof(header), &len, (u_char *)&header); if (header.checksum != SQUASHFS_MAGIC) { root_offset += master->erasesize - 1; root_offset &= ~(master->erasesize - 1); diff --git a/target/linux/ar7/files/drivers/net/cpmac.c b/target/linux/ar7/files/drivers/net/cpmac.c index 7d8e1b824..a8ed84ec8 100644 --- a/target/linux/ar7/files/drivers/net/cpmac.c +++ b/target/linux/ar7/files/drivers/net/cpmac.c @@ -1,18 +1,16 @@ /* - * $Id$ - * * Copyright (C) 2006, 2007 OpenWrt.org - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -23,7 +21,7 @@ #include <linux/moduleparam.h> #include <linux/sched.h> -#include <linux/kernel.h> /* printk() */ +#include <linux/kernel.h> #include <linux/slab.h> #include <linux/errno.h> #include <linux/types.h> @@ -45,7 +43,7 @@ MODULE_DESCRIPTION("TI AR7 ethernet driver (CPMAC)"); MODULE_LICENSE("GPL"); static int rx_ring_size = 64; -static int disable_napi = 0; +static int disable_napi; module_param(rx_ring_size, int, 64); module_param(disable_napi, int, 0); MODULE_PARM_DESC(rx_ring_size, "Size of rx ring (in skbs)"); @@ -53,40 +51,40 @@ MODULE_PARM_DESC(disable_napi, "Disable NAPI polling"); /* Register definitions */ struct cpmac_control_regs { - volatile u32 revision; - volatile u32 control; - volatile u32 teardown; - volatile u32 unused; + u32 revision; + u32 control; + u32 teardown; + u32 unused; } __attribute__ ((packed)); struct cpmac_int_regs { - volatile u32 stat_raw; - volatile u32 stat_masked; - volatile u32 enable; - volatile u32 clear; + u32 stat_raw; + u32 stat_masked; + u32 enable; + u32 clear; } __attribute__ ((packed)); struct cpmac_stats { - volatile u32 good; - volatile u32 bcast; - volatile u32 mcast; - volatile u32 pause; - volatile u32 crc_error; - volatile u32 align_error; - volatile u32 oversized; - volatile u32 jabber; - volatile u32 undersized; - volatile u32 fragment; - volatile u32 filtered; - volatile u32 qos_filtered; - volatile u32 octets; + u32 good; + u32 bcast; + u32 mcast; + u32 pause; + u32 crc_error; + u32 align_error; + u32 oversized; + u32 jabber; + u32 undersized; + u32 fragment; + u32 filtered; + u32 qos_filtered; + u32 octets; } __attribute__ ((packed)); struct cpmac_regs { struct cpmac_control_regs tx_ctrl; struct cpmac_control_regs rx_ctrl; - volatile u32 unused1[56]; - volatile u32 mbp; + u32 unused1[56]; + u32 mbp; /* MBP bits */ #define MBP_RXPASSCRC 0x40000000 #define MBP_RXQOS 0x20000000 @@ -100,15 +98,15 @@ struct cpmac_regs { #define MBP_BCASTCHAN(chan) (((chan) & 0x7) << 8) #define MBP_RXMCAST 0x00000020 #define MBP_MCASTCHAN(chan) ((chan) & 0x7) - volatile u32 unicast_enable; - volatile u32 unicast_clear; - volatile u32 max_len; - volatile u32 buffer_offset; - volatile u32 filter_flow_threshold; - volatile u32 unused2[2]; - volatile u32 flow_thre[8]; - volatile u32 free_buffer[8]; - volatile u32 mac_control; + u32 unicast_enable; + u32 unicast_clear; + u32 max_len; + u32 buffer_offset; + u32 filter_flow_threshold; + u32 unused2[2]; + u32 flow_thre[8]; + u32 free_buffer[8]; + u32 mac_control; #define MAC_TXPTYPE 0x00000200 #define MAC_TXPACE 0x00000040 #define MAC_MII 0x00000020 @@ -117,48 +115,48 @@ struct cpmac_regs { #define MAC_MTEST 0x00000004 #define MAC_LOOPBACK 0x00000002 #define MAC_FDX 0x00000001 - volatile u32 mac_status; + u32 mac_status; #define MACST_QOS 0x4 #define MACST_RXFLOW 0x2 #define MACST_TXFLOW 0x1 - volatile u32 emc_control; - volatile u32 unused3; + u32 emc_control; + u32 unused3; struct cpmac_int_regs tx_int; - volatile u32 mac_int_vector; + u32 mac_int_vector; /* Int Status bits */ #define INTST_STATUS 0x80000 #define INTST_HOST 0x40000 #define INTST_RX 0x20000 #define INTST_TX 0x10000 - volatile u32 mac_eoi_vector; - volatile u32 unused4[2]; + u32 mac_eoi_vector; + u32 unused4[2]; struct cpmac_int_regs rx_int; - volatile u32 mac_int_stat_raw; - volatile u32 mac_int_stat_masked; - volatile u32 mac_int_enable; - volatile u32 mac_int_clear; - volatile u32 mac_addr_low[8]; - volatile u32 mac_addr_mid; - volatile u32 mac_addr_high; - volatile u32 mac_hash_low; - volatile u32 mac_hash_high; - volatile u32 boff_test; - volatile u32 pac_test; - volatile u32 rx_pause; - volatile u32 tx_pause; - volatile u32 unused5[2]; + u32 mac_int_stat_raw; + u32 mac_int_stat_masked; + u32 mac_int_enable; + u32 mac_int_clear; + u32 mac_addr_low[8]; + u32 mac_addr_mid; + u32 mac_addr_high; + u32 mac_hash_low; + u32 mac_hash_high; + u32 boff_test; + u32 pac_test; + u32 rx_pause; + u32 tx_pause; + u32 unused5[2]; struct cpmac_stats rx_stats; struct cpmac_stats tx_stats; - volatile u32 unused6[232]; - volatile u32 tx_ptr[8]; - volatile u32 rx_ptr[8]; - volatile u32 tx_ack[8]; - volatile u32 rx_ack[8]; - + u32 unused6[232]; + u32 tx_ptr[8]; + u32 rx_ptr[8]; + u32 tx_ack[8]; + u32 rx_ack[8]; + } __attribute__ ((packed)); struct cpmac_mdio_regs { - volatile u32 version; + u32 version; volatile u32 control; #define MDIOC_IDLE 0x80000000 #define MDIOC_ENABLE 0x40000000 @@ -168,7 +166,7 @@ struct cpmac_mdio_regs { #define MDIOC_INTTEST 0x00020000 #define MDIOC_CLKDIV(div) ((div) & 0xff) volatile u32 alive; - volatile u32 link; + u32 link; struct cpmac_int_regs link_int; struct cpmac_int_regs user_int; u32 unused[20]; @@ -178,7 +176,7 @@ struct cpmac_mdio_regs { #define MDIO_REG(reg) (((reg) & 0x1f) << 21) #define MDIO_PHY(phy) (((phy) & 0x1f) << 16) #define MDIO_DATA(data) ((data) & 0xffff) - volatile u32 physel; + u32 physel; } __attribute__ ((packed)); /* Descriptor */ @@ -200,7 +198,7 @@ struct cpmac_desc { struct cpmac_priv { struct net_device_stats stats; - spinlock_t lock; + spinlock_t lock; /* irq{save,restore} */ struct sk_buff *skb_pool; int free_skbs; struct cpmac_desc *rx_head; @@ -234,29 +232,28 @@ static void cpmac_dump_regs(u32 *base, int count) { int i; for (i = 0; i < (count + 3) / 4; i++) { - if (i % 4 == 0) printk("\nCPMAC[0x%04x]:", i * 4); - printk(" 0x%08x", *(base + i)); + if (i % 4 == 0) printk(KERN_DEBUG "\nCPMAC[0x%04x]:", i * 4); + printk(KERN_DEBUG " 0x%08x", *(base + i)); } - printk("\n"); + printk(KERN_DEBUG "\n"); } -static const char *cpmac_dump_buf(const uint8_t * buf, unsigned size) +static const char *cpmac_dump_buf(const uint8_t *buf, unsigned size) { static char buffer[3 * 25 + 1]; char *p = &buffer[0]; if (size > 20) size = 20; - while (size-- > 0) { + while (size-- > 0) p += sprintf(p, " %02x", *buf++); - } return buffer; } #endif static int cpmac_mdio_read(struct mii_bus *bus, int phy_id, int regnum) { - struct cpmac_mdio_regs *regs = (struct cpmac_mdio_regs *)bus->priv; - volatile u32 val; + struct cpmac_mdio_regs *regs = bus->priv; + u32 val; while ((val = regs->access) & MDIO_BUSY); regs->access = MDIO_BUSY | MDIO_REG(regnum & 0x1f) | @@ -266,13 +263,14 @@ static int cpmac_mdio_read(struct mii_bus *bus, int phy_id, int regnum) return val & 0xffff; } -static int cpmac_mdio_write(struct mii_bus *bus, int phy_id, int regnum, u16 val) +static int cpmac_mdio_write(struct mii_bus *bus, int phy_id, + int regnum, u16 val) { - struct cpmac_mdio_regs *regs = (struct cpmac_mdio_regs *)bus->priv; - volatile u32 tmp; + struct cpmac_mdio_regs *regs = bus->priv; + u32 tmp; while ((tmp = regs->access) & MDIO_BUSY); - regs->access = MDIO_BUSY | MDIO_WRITE | + regs->access = MDIO_BUSY | MDIO_WRITE | MDIO_REG(regnum & 0x1f) | MDIO_PHY(phy_id & 0x1f) | val; @@ -281,7 +279,7 @@ static int cpmac_mdio_write(struct mii_bus *bus, int phy_id, int regnum, u16 val static int cpmac_mdio_reset(struct mii_bus *bus) { - struct cpmac_mdio_regs *regs = (struct cpmac_mdio_regs *)bus->priv; + struct cpmac_mdio_regs *regs = bus->priv; ar7_device_reset(AR7_RESET_BIT_MDIO); regs->control = MDIOC_ENABLE | @@ -333,17 +331,17 @@ static void cpmac_set_multicast_list(struct net_device *dev) int hashlo = 0, hashhi = 0; struct cpmac_priv *priv = netdev_priv(dev); - if(dev->flags & IFF_PROMISC) { + if (dev->flags & IFF_PROMISC) { priv->regs->mbp &= ~MBP_PROMISCCHAN(0); /* promisc channel 0 */ priv->regs->mbp |= MBP_RXPROMISC; } else { priv->regs->mbp &= ~MBP_RXPROMISC; - if(dev->flags & IFF_ALLMULTI) { + if (dev->flags & IFF_ALLMULTI) { /* enable all multicast mode */ priv->regs->mac_hash_low = 0xffffffff; priv->regs->mac_hash_high = 0xffffffff; } else { - for(i = 0, iter = dev->mc_list; i < dev->mc_count; + for (i = 0, iter = dev->mc_list; i < dev->mc_count; i++, iter = iter->next) { hash = 0; tmp = iter->dmi_addr[0]; @@ -359,7 +357,7 @@ static void cpmac_set_multicast_list(struct net_device *dev) tmp = iter->dmi_addr[6]; hash ^= (tmp >> 6) ^ tmp; hash &= 0x3f; - if(hash < 32) { + if (hash < 32) { hashlo |= 1<<hash; } else { hashhi |= 1<<(hash - 32); @@ -372,15 +370,15 @@ static void cpmac_set_multicast_list(struct net_device *dev) } } -static struct sk_buff *cpmac_get_skb(struct net_device *dev) +static struct sk_buff *cpmac_get_skb(struct net_device *dev) { struct sk_buff *skb; struct cpmac_priv *priv = netdev_priv(dev); skb = priv->skb_pool; - if (likely(skb)) { + if (likely(skb)) priv->skb_pool = skb->next; - } else { + else { skb = dev_alloc_skb(CPMAC_SKB_SIZE + 2); if (skb) { skb->next = NULL; @@ -398,7 +396,7 @@ static struct sk_buff *cpmac_get_skb(struct net_device *dev) return skb; } -static inline struct sk_buff *cpmac_rx_one(struct net_device *dev, +static struct sk_buff *cpmac_rx_one(struct net_device *dev, struct cpmac_priv *priv, struct cpmac_desc *desc) { @@ -430,7 +428,7 @@ static inline struct sk_buff *cpmac_rx_one(struct net_device *dev, } else { #ifdef CPMAC_DEBUG if (printk_ratelimit()) - printk("%s: low on skbs, dropping packet\n", + printk(KERN_NOTICE "%s: low on skbs, dropping packet\n", dev->name); #endif priv->stats.rx_dropped++; @@ -466,9 +464,8 @@ static void cpmac_rx(struct net_device *dev) while ((desc->dataflags & CPMAC_OWN) == 0) { skb = cpmac_rx_one(dev, priv, desc); - if (likely(skb)) { + if (likely(skb)) netif_rx(skb); - } desc = desc->next; dma_cache_inv((u32)desc, 16); } @@ -487,7 +484,7 @@ static int cpmac_poll(struct net_device *dev, int *budget) if (unlikely(!priv->rx_head)) { if (printk_ratelimit()) - printk(KERN_WARNING "%s: rx: polling, but no queue\n", + printk(KERN_NOTICE "%s: rx: polling, but no queue\n", dev->name); netif_rx_complete(dev); return 0; @@ -495,7 +492,7 @@ static int cpmac_poll(struct net_device *dev, int *budget) desc = priv->rx_head; dma_cache_inv((u32)desc, 16); - + while ((received < quota) && ((desc->dataflags & CPMAC_OWN) == 0)) { skb = cpmac_rx_one(dev, priv, desc); if (likely(skb)) { @@ -510,7 +507,7 @@ static int cpmac_poll(struct net_device *dev, int *budget) *budget -= received; dev->quota -= received; #ifdef CPMAC_DEBUG - printk("%s: processed %d packets\n", dev->name, received); + printk(KERN_DEBUG "%s: processed %d packets\n", dev->name, received); #endif if (desc->dataflags & CPMAC_OWN) { priv->regs->rx_ptr[0] = virt_to_phys(desc); @@ -523,19 +520,11 @@ static int cpmac_poll(struct net_device *dev, int *budget) return 1; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) static void cpmac_alloc_skbs(struct work_struct *work) { struct cpmac_priv *priv = container_of(work, struct cpmac_priv, - alloc_work); -#else -static void -cpmac_alloc_skbs(void *data) -{ - struct net_device *dev = (struct net_device*)data; - struct cpmac_priv *priv = netdev_priv(dev); -#endif + alloc_work); unsigned long flags; int i, num_skbs = 0; struct sk_buff *skb, *skbs = NULL; @@ -554,15 +543,15 @@ cpmac_alloc_skbs(void *data) if (skbs) { spin_lock_irqsave(&priv->lock, flags); for (skb = priv->skb_pool; skb && skb->next; skb = skb->next); - if (!skb) { + if (!skb) priv->skb_pool = skbs; - } else { + else skb->next = skbs; - } priv->free_skbs += num_skbs; spin_unlock_irqrestore(&priv->lock, flags); #ifdef CPMAC_DEBUG - printk("%s: allocated %d skbs\n", priv->dev->name, num_skbs); + printk(KERN_DEBUG "%s: allocated %d skbs\n", + priv->dev->name, num_skbs); #endif } } @@ -576,13 +565,15 @@ static int cpmac_start_xmit(struct sk_buff *skb, struct net_device *dev) len = skb->len; #ifdef CPMAC_DEBUG - printk(KERN_DEBUG "%s: len=%d\n", __func__, len); //cpmac_dump_buf(const uint8_t * buf, unsigned size) + printk(KERN_DEBUG "%s: len=%d\n", __func__, len); + /* cpmac_dump_buf(const uint8_t * buf, unsigned size) */ #endif if (unlikely(len < ETH_ZLEN)) { if (unlikely(skb_padto(skb, ETH_ZLEN))) { if (printk_ratelimit()) - printk(KERN_NOTICE "%s: padding failed, dropping\n", - dev->name); + printk(KERN_NOTICE + "%s: padding failed, dropping\n", + dev->name); spin_lock_irqsave(&priv->lock, flags); priv->stats.tx_dropped++; spin_unlock_irqrestore(&priv->lock, flags); @@ -599,7 +590,8 @@ static int cpmac_start_xmit(struct sk_buff *skb, struct net_device *dev) desc = &priv->desc_ring[chan]; dma_cache_inv((u32)desc, 16); if (desc->dataflags & CPMAC_OWN) { - printk(KERN_NOTICE "%s: tx dma ring full, dropping\n", dev->name); + printk(KERN_NOTICE "%s: tx dma ring full, dropping\n", + dev->name); priv->stats.tx_dropped++; spin_unlock_irqrestore(&priv->lock, flags); return -ENOMEM; @@ -634,11 +626,10 @@ static void cpmac_end_xmit(struct net_device *dev, int channel) dev_kfree_skb_irq(desc->skb); if (netif_queue_stopped(dev)) netif_wake_queue(dev); - } else { + } else if (printk_ratelimit()) printk(KERN_NOTICE "%s: end_xmit: spurious interrupt\n", - dev->name); - } + dev->name); spin_unlock(&priv->lock); } @@ -668,7 +659,7 @@ static inline void cpmac_free_rx_ring(struct net_device *dev) desc = priv->rx_head; dma_cache_inv((u32)desc, 16); - + for (i = 0; i < rx_ring_size; i++) { desc->buflen = CPMAC_SKB_SIZE; if ((desc->dataflags & CPMAC_OWN) == 0) { @@ -683,7 +674,7 @@ static inline void cpmac_free_rx_ring(struct net_device *dev) static irqreturn_t cpmac_irq(int irq, void *dev_id) { - struct net_device *dev = (struct net_device *)dev_id; + struct net_device *dev = dev_id; struct cpmac_priv *priv = netdev_priv(dev); u32 status; @@ -692,14 +683,13 @@ static irqreturn_t cpmac_irq(int irq, void *dev_id) status = priv->regs->mac_int_vector; - if (status & INTST_TX) { + if (status & INTST_TX) cpmac_end_xmit(dev, (status & 7)); - } if (status & INTST_RX) { - if (disable_napi) { + if (disable_napi) cpmac_rx(dev); - } else { + else { priv->regs->rx_int.enable = 0; priv->regs->rx_int.clear = 0xff; netif_rx_schedule(dev); @@ -709,9 +699,9 @@ static irqreturn_t cpmac_irq(int irq, void *dev_id) priv->regs->mac_eoi_vector = 0; if (unlikely(status & (INTST_HOST | INTST_STATUS))) { - if (printk_ratelimit()) { - printk(KERN_ERR "%s: hw error, resetting...\n", dev->name); - } + if (printk_ratelimit()) + printk(KERN_ERR "%s: hw error, resetting...\n", + dev->name); spin_lock(&priv->lock); phy_stop(priv->phy); cpmac_reset(dev); @@ -731,7 +721,7 @@ static void cpmac_tx_timeout(struct net_device *dev) priv->stats.tx_errors++; desc = &priv->desc_ring[priv->tx_head++]; priv->tx_head %= 8; - printk("%s: transmit timeout\n", dev->name); + printk(KERN_NOTICE "%s: transmit timeout\n", dev->name); if (desc->skb) dev_kfree_skb(desc->skb); netif_wake_queue(dev); @@ -744,7 +734,7 @@ static int cpmac_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) return -EINVAL; if (!priv->phy) return -EINVAL; - if ((cmd == SIOCGMIIPHY) || (cmd == SIOCGMIIREG) || + if ((cmd == SIOCGMIIPHY) || (cmd == SIOCGMIIREG) || (cmd == SIOCSMIIREG)) return phy_mii_ioctl(priv->phy, if_mii(ifr), cmd); @@ -774,7 +764,7 @@ static int cpmac_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) return -EINVAL; } -static void cpmac_get_drvinfo(struct net_device *dev, +static void cpmac_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { strcpy(info->driver, "cpmac"); @@ -894,12 +884,8 @@ static int cpmac_open(struct net_device *dev) struct cpmac_desc *desc; struct sk_buff *skb; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) priv->phy = phy_connect(dev, priv->phy_name, &cpmac_adjust_link, 0, PHY_INTERFACE_MODE_MII); -#else - priv->phy = phy_connect(dev, priv->phy_name, &cpmac_adjust_link, 0); -#endif if (IS_ERR(priv->phy)) { printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name); return PTR_ERR(priv->phy); @@ -907,8 +893,8 @@ static int cpmac_open(struct net_device *dev) if (!request_mem_region(dev->mem_start, dev->mem_end - dev->mem_start, dev->name)) { - printk("%s: failed to request registers\n", - dev->name); + printk(KERN_ERR "%s: failed to request registers\n", + dev->name); res = -ENXIO; goto fail_reserve; } @@ -916,7 +902,7 @@ static int cpmac_open(struct net_device *dev) priv->regs = ioremap_nocache(dev->mem_start, dev->mem_end - dev->mem_start); if (!priv->regs) { - printk("%s: failed to remap registers\n", dev->name); + printk(KERN_ERR "%s: failed to remap registers\n", dev->name); res = -ENXIO; goto fail_remap; } @@ -936,11 +922,7 @@ static int cpmac_open(struct net_device *dev) priv->free_skbs = 0; priv->rx_head = &priv->desc_ring[CPMAC_TX_RING_SIZE]; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) INIT_WORK(&priv->alloc_work, cpmac_alloc_skbs); -#else - INIT_WORK(&priv->alloc_work, cpmac_alloc_skbs, dev); -#endif schedule_work(&priv->alloc_work); flush_scheduled_work(); @@ -960,9 +942,9 @@ static int cpmac_open(struct net_device *dev) dma_cache_wback((u32)desc, 16); } - if((res = request_irq(dev->irq, cpmac_irq, SA_INTERRUPT, - dev->name, dev))) { - printk("%s: failed to obtain irq\n", dev->name); + if ((res = request_irq(dev->irq, cpmac_irq, SA_INTERRUPT, + dev->name, dev))) { + printk(KERN_ERR "%s: failed to obtain irq\n", dev->name); goto fail_irq; } @@ -1039,7 +1021,7 @@ static int cpmac_stop(struct net_device *dev) return 0; } -static int external_switch = 0; +static int external_switch; static int __devinit cpmac_probe(struct platform_device *pdev) { @@ -1049,9 +1031,6 @@ static int __devinit cpmac_probe(struct platform_device *pdev) struct net_device *dev; struct plat_cpmac_data *pdata; - if (strcmp(pdev->name, "cpmac") != 0) - return -ENODEV; - pdata = pdev->dev.platform_data; for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) { @@ -1063,10 +1042,10 @@ static int __devinit cpmac_probe(struct platform_device *pdev) } if (phy_id == PHY_MAX_ADDR) { - if (external_switch) { + if (external_switch) phy_id = 0; - } else { - printk("cpmac: no PHY present\n"); + else { + printk(KERN_ERR "cpmac: no PHY present\n"); return -ENODEV; } } @@ -1074,7 +1053,8 @@ static int __devinit cpmac_probe(struct platform_device *pdev) dev = alloc_etherdev(sizeof(struct cpmac_priv)); if (!dev) { - printk(KERN_ERR "cpmac: Unable to allocate net_device structure!\n"); + printk(KERN_ERR + "cpmac: Unable to allocate net_device structure!\n"); return -ENOMEM; } @@ -1084,7 +1064,7 @@ static int __devinit cpmac_probe(struct platform_device *pdev) res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); if (!res) { - rc = -ENODEV; + rc = -ENODEV; goto fail; } @@ -1099,8 +1079,8 @@ static int __devinit cpmac_probe(struct platform_device *pdev) dev->hard_start_xmit = cpmac_start_xmit; dev->do_ioctl = cpmac_ioctl; dev->get_stats = cpmac_stats; - dev->change_mtu = cpmac_change_mtu; - dev->set_mac_address = cpmac_set_mac_address; + dev->change_mtu = cpmac_change_mtu; + dev->set_mac_address = cpmac_set_mac_address; dev->set_multicast_list = cpmac_set_multicast_list; dev->tx_timeout = cpmac_tx_timeout; dev->ethtool_ops = &cpmac_ethtool_ops; @@ -1115,27 +1095,23 @@ static int __devinit cpmac_probe(struct platform_device *pdev) priv->config = pdata; priv->dev = dev; memcpy(dev->dev_addr, priv->config->dev_addr, sizeof(dev->dev_addr)); - if (phy_id == 31) { + if (phy_id == 31) snprintf(priv->phy_name, BUS_ID_SIZE, PHY_ID_FMT, cpmac_mii.id, phy_id); - } else { + else snprintf(priv->phy_name, BUS_ID_SIZE, "fixed@%d:%d", 100, 1); - } if ((rc = register_netdev(dev))) { - printk("cpmac: error %i registering device %s\n", + printk(KERN_ERR "cpmac: error %i registering device %s\n", rc, dev->name); goto fail; } - printk("cpmac: device %s (regs: %p, irq: %d, phy: %s, mac: ", + printk(KERN_INFO "cpmac: device %s (regs: %p, irq: %d, phy: %s, mac: ", dev->name, (u32 *)dev->mem_start, dev->irq, priv->phy_name); - for (i = 0; i < 6; i++) { - printk("%02x", dev->dev_addr[i]); - if (i < 5) printk(":"); - else printk(")\n"); - } + for (i = 0; i < 6; i++) + printk("%02x%s", dev->dev_addr[i], i < 5 ? ":" : ")\n"); return 0; @@ -1160,13 +1136,13 @@ static struct platform_driver cpmac_driver = { int __devinit cpmac_init(void) { - volatile u32 mask; + u32 mask; int i, res; - cpmac_mii.priv = (struct cpmac_mdio_regs *) + cpmac_mii.priv = ioremap_nocache(AR7_REGS_MDIO, sizeof(struct cpmac_mdio_regs)); if (!cpmac_mii.priv) { - printk("Can't ioremap mdio registers\n"); + printk(KERN_ERR "Can't ioremap mdio registers\n"); return -ENXIO; } diff --git a/target/linux/ar7/files/include/asm-mips/ar7/ar7.h b/target/linux/ar7/files/include/asm-mips/ar7/ar7.h index 5ed005e8d..89e8b305a 100644 --- a/target/linux/ar7/files/include/asm-mips/ar7/ar7.h +++ b/target/linux/ar7/files/include/asm-mips/ar7/ar7.h @@ -1,18 +1,16 @@ /* - * $Id$ - * * Copyright (C) 2006, 2007 OpenWrt.org - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -23,53 +21,54 @@ #include <linux/delay.h> #include <asm/addrspace.h> -#include <asm/io.h> - -#define AR7_REGS_BASE 0x08610000 - -#define AR7_REGS_MAC0 (AR7_REGS_BASE + 0x0000) -#define AR7_REGS_GPIO (AR7_REGS_BASE + 0x0900) -#define AR7_REGS_POWER (AR7_REGS_BASE + 0x0a00) // 0x08610A00 - 0x08610BFF (512 bytes, 128 bytes / clock) -#define AR7_REGS_UART0 (AR7_REGS_BASE + 0x0e00) -#define AR7_REGS_RESET (AR7_REGS_BASE + 0x1600) -#define AR7_REGS_VLYNQ0 (AR7_REGS_BASE + 0x1800) -#define AR7_REGS_DCL (AR7_REGS_BASE + 0x1a00) -#define AR7_REGS_VLYNQ1 (AR7_REGS_BASE + 0x1c00) -#define AR7_REGS_MDIO (AR7_REGS_BASE + 0x1e00) -#define AR7_REGS_IRQ (AR7_REGS_BASE + 0x2400) -#define AR7_REGS_MAC1 (AR7_REGS_BASE + 0x2800) - -#define AR7_REGS_WDT (AR7_REGS_BASE + 0x1f00) -#define UR8_REGS_WDT (AR7_REGS_BASE + 0x0b00) -#define UR8_REGS_UART1 (AR7_REGS_BASE + 0x0f00) - -#define AR7_RESET_PEREPHERIAL 0x0 -#define AR7_RESET_SOFTWARE 0x4 -#define AR7_RESET_STATUS 0x8 - -#define AR7_RESET_BIT_CPMAC_LO 17 -#define AR7_RESET_BIT_CPMAC_HI 21 -#define AR7_RESET_BIT_MDIO 22 -#define AR7_RESET_BIT_EPHY 26 +#include <linux/io.h> + +#define AR7_REGS_BASE 0x08610000 + +#define AR7_REGS_MAC0 (AR7_REGS_BASE + 0x0000) +#define AR7_REGS_GPIO (AR7_REGS_BASE + 0x0900) +/* 0x08610A00 - 0x08610BFF (512 bytes, 128 bytes / clock) */ +#define AR7_REGS_POWER (AR7_REGS_BASE + 0x0a00) +#define AR7_REGS_UART0 (AR7_REGS_BASE + 0x0e00) +#define AR7_REGS_RESET (AR7_REGS_BASE + 0x1600) +#define AR7_REGS_VLYNQ0 (AR7_REGS_BASE + 0x1800) +#define AR7_REGS_DCL (AR7_REGS_BASE + 0x1a00) +#define AR7_REGS_VLYNQ1 (AR7_REGS_BASE + 0x1c00) +#define AR7_REGS_MDIO (AR7_REGS_BASE + 0x1e00) +#define AR7_REGS_IRQ (AR7_REGS_BASE + 0x2400) +#define AR7_REGS_MAC1 (AR7_REGS_BASE + 0x2800) + +#define AR7_REGS_WDT (AR7_REGS_BASE + 0x1f00) +#define UR8_REGS_WDT (AR7_REGS_BASE + 0x0b00) +#define UR8_REGS_UART1 (AR7_REGS_BASE + 0x0f00) + +#define AR7_RESET_PEREPHERIAL 0x0 +#define AR7_RESET_SOFTWARE 0x4 +#define AR7_RESET_STATUS 0x8 + +#define AR7_RESET_BIT_CPMAC_LO 17 +#define AR7_RESET_BIT_CPMAC_HI 21 +#define AR7_RESET_BIT_MDIO 22 +#define AR7_RESET_BIT_EPHY 26 /* GPIO control registers */ -#define AR7_GPIO_INPUT 0x0 -#define AR7_GPIO_OUTPUT 0x4 -#define AR7_GPIO_DIR 0x8 -#define AR7_GPIO_ENABLE 0xc +#define AR7_GPIO_INPUT 0x0 +#define AR7_GPIO_OUTPUT 0x4 +#define AR7_GPIO_DIR 0x8 +#define AR7_GPIO_ENABLE 0xc -#define AR7_CHIP_7100 0x18 -#define AR7_CHIP_7200 0x2b -#define AR7_CHIP_7300 0x05 +#define AR7_CHIP_7100 0x18 +#define AR7_CHIP_7200 0x2b +#define AR7_CHIP_7300 0x05 /* Interrupts */ -#define AR7_IRQ_UART0 15 -#define AR7_IRQ_UART1 16 +#define AR7_IRQ_UART0 15 +#define AR7_IRQ_UART1 16 /* Clocks */ -#define AR7_AFE_CLOCK 35328000 -#define AR7_REF_CLOCK 25000000 -#define AR7_XTAL_CLOCK 24000000 +#define AR7_AFE_CLOCK 35328000 +#define AR7_REF_CLOCK 25000000 +#define AR7_XTAL_CLOCK 24000000 struct plat_cpmac_data { int reset_bit; @@ -132,14 +131,16 @@ static inline int ar7_has_high_cpmac(void) static inline void ar7_device_enable(u32 bit) { - void *reset_reg = (void *)KSEG1ADDR(AR7_REGS_RESET + AR7_RESET_PEREPHERIAL); + void *reset_reg = + (void *)KSEG1ADDR(AR7_REGS_RESET + AR7_RESET_PEREPHERIAL); writel(readl(reset_reg) | (1 << bit), reset_reg); mdelay(20); } static inline void ar7_device_disable(u32 bit) { - void *reset_reg = (void *)KSEG1ADDR(AR7_REGS_RESET + AR7_RESET_PEREPHERIAL); + void *reset_reg = + (void *)KSEG1ADDR(AR7_REGS_RESET + AR7_RESET_PEREPHERIAL); writel(readl(reset_reg) & ~(1 << bit), reset_reg); mdelay(20); } diff --git a/target/linux/ar7/files/include/asm-mips/ar7/gpio.h b/target/linux/ar7/files/include/asm-mips/ar7/gpio.h index 1cb11a377..c82ba78cf 100644 --- a/target/linux/ar7/files/include/asm-mips/ar7/gpio.h +++ b/target/linux/ar7/files/include/asm-mips/ar7/gpio.h @@ -1,18 +1,16 @@ /* - * $Id: gpio.h 6693 2007-03-25 05:42:16Z ejka $ - * * Copyright (C) 2007 OpenWrt.org - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -30,7 +28,8 @@ extern void gpio_free(unsigned gpio); /* Common GPIO layer */ static inline int gpio_direction_input(unsigned gpio) { - void __iomem *gpio_dir = (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_DIR); + void __iomem *gpio_dir = + (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_DIR); if (gpio >= AR7_GPIO_MAX) return -EINVAL; @@ -42,7 +41,8 @@ static inline int gpio_direction_input(unsigned gpio) static inline int gpio_direction_output(unsigned gpio) { - void __iomem *gpio_dir = (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_DIR); + void __iomem *gpio_dir = + (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_DIR); if (gpio >= AR7_GPIO_MAX) return -EINVAL; @@ -54,7 +54,8 @@ static inline int gpio_direction_output(unsigned gpio) static inline int gpio_get_value(unsigned gpio) { - void __iomem *gpio_in = (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_INPUT); + void __iomem *gpio_in = + (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_INPUT); if (gpio >= AR7_GPIO_MAX) return -EINVAL; @@ -64,14 +65,15 @@ static inline int gpio_get_value(unsigned gpio) static inline void gpio_set_value(unsigned gpio, int value) { - void __iomem *gpio_out = (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_OUTPUT); + void __iomem *gpio_out = + (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_OUTPUT); volatile unsigned tmp; if (gpio >= AR7_GPIO_MAX) return; tmp = readl(gpio_out) & ~(1 << gpio); - if (value) + if (value) tmp |= 1 << gpio; writel(tmp, gpio_out); } @@ -89,7 +91,8 @@ static inline int irq_to_gpio(unsigned irq) /* Board specific GPIO functions */ static inline int ar7_gpio_enable(unsigned gpio) { - void __iomem *gpio_en = (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_ENABLE); + void __iomem *gpio_en = + (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_ENABLE); if (gpio >= AR7_GPIO_MAX) return -EINVAL; @@ -101,7 +104,8 @@ static inline int ar7_gpio_enable(unsigned gpio) static inline int ar7_gpio_disable(unsigned gpio) { - void __iomem *gpio_en = (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_ENABLE); + void __iomem *gpio_en = + (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_ENABLE); if (gpio >= AR7_GPIO_MAX) return -EINVAL; diff --git a/target/linux/ar7/files/include/asm-mips/ar7/mmzone.h b/target/linux/ar7/files/include/asm-mips/ar7/mmzone.h index 885fdb0cb..59d9c712f 100644 --- a/target/linux/ar7/files/include/asm-mips/ar7/mmzone.h +++ b/target/linux/ar7/files/include/asm-mips/ar7/mmzone.h @@ -1,18 +1,16 @@ /* - * $Id$ - * * Copyright (C) 2007 OpenWrt.org - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -22,8 +20,8 @@ #define _ASM_MACH_MMZONE_H extern pg_data_t __node_data[]; -#define NODE_DATA(nid) (&__node_data[nid]) -#define NODE_MEM_MAP(nid) (NODE_DATA(nid)->node_mem_map) -#define pa_to_nid(addr) (((addr) >= ARCH_PFN_OFFSET << PAGE_SHIFT) ? 0 : -1) +#define NODE_DATA(nid) (&__node_data[nid]) +#define NODE_MEM_MAP(nid) (NODE_DATA(nid)->node_mem_map) +#define pa_to_nid(addr) (((addr) >= ARCH_PFN_OFFSET << PAGE_SHIFT) ? 0 : -1) #endif /* _ASM_MACH_MMZONE_H */ diff --git a/target/linux/ar7/files/include/asm-mips/ar7/prom.h b/target/linux/ar7/files/include/asm-mips/ar7/prom.h index 138941737..0aa2af4b2 100644 --- a/target/linux/ar7/files/include/asm-mips/ar7/prom.h +++ b/target/linux/ar7/files/include/asm-mips/ar7/prom.h @@ -1,18 +1,16 @@ /* - * $Id$ - * * Copyright (C) 2006, 2007 OpenWrt.org - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA diff --git a/target/linux/ar7/files/include/asm-mips/ar7/vlynq.h b/target/linux/ar7/files/include/asm-mips/ar7/vlynq.h index 2e558c1c5..34b940759 100644 --- a/target/linux/ar7/files/include/asm-mips/ar7/vlynq.h +++ b/target/linux/ar7/files/include/asm-mips/ar7/vlynq.h @@ -1,18 +1,16 @@ /* - * $Id$ - * * Copyright (C) 2006, 2007 OpenWrt.org - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -65,7 +63,7 @@ struct plat_vlynq_ops { extern struct bus_type vlynq_bus_type; -extern int __vlynq_register_driver(struct vlynq_driver *driver, +extern int __vlynq_register_driver(struct vlynq_driver *driver, struct module *owner); static inline int vlynq_register_driver(struct vlynq_driver *driver) @@ -80,8 +78,8 @@ extern u32 vlynq_remote_id(struct vlynq_device *dev); extern void vlynq_set_local_mapping(struct vlynq_device *dev, u32 tx_offset, struct vlynq_mapping *mapping); -extern void vlynq_set_remote_mapping(struct vlynq_device *dev, - u32 tx_offset, +extern void vlynq_set_remote_mapping(struct vlynq_device *dev, + u32 tx_offset, struct vlynq_mapping *mapping); extern int vlynq_virq_to_irq(struct vlynq_device *dev, int virq); extern int vlynq_irq_to_virq(struct vlynq_device *dev, int irq); |