#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/init.h>
+#include <linux/io.h>
-#include <asm/io.h>
#include <asm/bootinfo.h>
#include <asm/addrspace.h>
#include <adm5120_board.h>
#include <adm5120_platform.h>
+#define PFX "adm5120: "
+
static LIST_HEAD(adm5120_boards);
static char adm5120_board_name[ADM5120_BOARD_NAMELEN];
board = adm5120_board_find(mips_machtype);
if (board == NULL) {
- printk(KERN_ALERT "adm5120: no board registered for machtype %lu"
- ", trying generic\n", mips_machtype);
+ printk(KERN_ALERT PFX"no board registered for "
+ "machtype %lu, trying generic\n", mips_machtype);
board = adm5120_board_find(MACH_ADM5120_GENERIC);
if (board == NULL)
- panic("adm5120: unsupported board\n");
+ panic(PFX "unsupported board\n");
}
- printk(KERN_INFO "adm5120: setting up board '%s'\n", board->name);
+ printk(KERN_INFO PFX "setting up board '%s'\n", board->name);
memcpy(&adm5120_board_name, board->name, ADM5120_BOARD_NAMELEN);
adm5120_pci_set_irq_map(board->pci_nr_irqs, board->pci_irq_map);
/* register board devices */
- if (board->num_devices > 0 && board->devices != NULL ) {
+ if (board->num_devices > 0 && board->devices != NULL) {
err = platform_add_devices(board->devices, board->num_devices);
if (err)
- printk(KERN_ALERT "adm5120: adding board devices failed\n");
+ printk(KERN_ALERT PFX "adding board devices failed\n");
}
return 0;
void __init adm5120_board_register(struct adm5120_board *board)
{
list_add(&board->list, &adm5120_boards);
- printk(KERN_INFO "adm5120: registered board '%s'\n", board->name);
+ printk(KERN_INFO PFX "registered board '%s'\n", board->name);
}
void __init adm5120_register_boards(struct adm5120_board **boards,
{
int i;
- for (i=0; i<num; i++)
+ for (i = 0; i < num; i++)
adm5120_board_register(boards[i]);
}
#define RB150_NAND_DELAY 100
#define RB150_NAND_WRITE(v) \
- writeb((v),(void __iomem *)KSEG1ADDR(RB150_NAND_BASE))
+ writeb((v), (void __iomem *)KSEG1ADDR(RB150_NAND_BASE))
/*--------------------------------------------------------------------------*/
PCIIRQ(3, 0, 1, ADM5120_IRQ_PCI2)
};
-static struct mtd_partition rb1xx_nor_partitions[] = {
+static struct mtd_partition rb1xx_nor_parts[] = {
{
.name = "booter",
.offset = 0,
}
};
-static struct mtd_partition rb1xx_nand_partitions[] = {
+static struct mtd_partition rb1xx_nand_parts[] = {
{
.name = "kernel",
.offset = 0,
* when creating the partitions
*/
static struct nand_ecclayout rb1xx_nand_ecclayout = {
- .eccbytes = 6,
- .eccpos = { 8, 9, 10, 13, 14, 15 },
- .oobavail = 9,
- .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
+ .eccbytes = 6,
+ .eccpos = { 8, 9, 10, 13, 14, 15 },
+ .oobavail = 9,
+ .oobfree = { { 0, 4 }, { 6, 2 }, { 11, 2 }, { 4, 1 } }
};
static struct resource rb150_nand_resource[] = {
/*--------------------------------------------------------------------------*/
-static int rb150_nand_ready(struct mtd_info *mtd) {
-
+static int rb150_nand_ready(struct mtd_info *mtd)
+{
return gpio_get_value(RB150_GPIO_NAND_READY);
}
static void __init rb1xx_flash_setup(void)
{
/* setup data for flash0 device */
- adm5120_flash0_data.nr_parts = ARRAY_SIZE(rb1xx_nor_partitions);
- adm5120_flash0_data.parts = rb1xx_nor_partitions;
+ adm5120_flash0_data.nr_parts = ARRAY_SIZE(rb1xx_nor_parts);
+ adm5120_flash0_data.parts = rb1xx_nor_parts;
/* setup data for NAND device */
adm5120_nand_data.chip.nr_chips = 1;
- adm5120_nand_data.chip.nr_partitions = ARRAY_SIZE(rb1xx_nand_partitions);
- adm5120_nand_data.chip.partitions = rb1xx_nand_partitions;
+ adm5120_nand_data.chip.nr_partitions = ARRAY_SIZE(rb1xx_nand_parts);
+ adm5120_nand_data.chip.partitions = rb1xx_nand_parts;
adm5120_nand_data.chip.ecclayout = &rb1xx_nand_ecclayout;
adm5120_nand_data.chip.chip_delay = RB1XX_NAND_CHIP_DELAY;
adm5120_nand_data.chip.options = NAND_NO_AUTOINCR;
#include <linux/err.h>
#include <linux/clk.h>
-#include <asm/mach-adm5120/adm5120_defs.h>
+#include <adm5120_defs.h>
struct clk {
unsigned long rate;
struct clk *clk_get(struct device *dev, const char *id)
{
- if (!strcmp(id, "UARTCLK"))
- return &uart_clk;
+ if (!strcmp(id, "UARTCLK"))
+ return &uart_clk;
- return ERR_PTR(-ENOENT);
+ return ERR_PTR(-ENOENT);
}
EXPORT_SYMBOL(clk_get);
int clk_enable(struct clk *clk)
{
- return 0;
+ return 0;
}
EXPORT_SYMBOL(clk_enable);
unsigned long clk_get_rate(struct clk *clk)
{
- return clk->rate;
+ return clk->rate;
}
EXPORT_SYMBOL(clk_get_rate);
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
+#include <linux/io.h>
#include <asm/addrspace.h>
-#include <asm/io.h>
#include <asm/gpio.h>
-#include <asm/mach-adm5120/adm5120_defs.h>
-#include <asm/mach-adm5120/adm5120_info.h>
-#include <asm/mach-adm5120/adm5120_switch.h>
+#include <adm5120_defs.h>
+#include <adm5120_info.h>
+#include <adm5120_switch.h>
-typedef void __iomem * gpio_reg_t;
-#define GPIO_READ(r) readl((r))
-#define GPIO_WRITE(v,r) writel((v),(r))
-#define GPIO_REG(r) (gpio_reg_t)(KSEG1ADDR(ADM5120_SWITCH_BASE)+r)
+
+#define GPIO_READ(r) readl((r))
+#define GPIO_WRITE(v, r) writel((v), (r))
+#define GPIO_REG(r) (void __iomem *)(KSEG1ADDR(ADM5120_SWITCH_BASE)+r)
struct adm5120_gpio_line {
u32 flags;
#define GPIO_FLAG_USED 0x02
struct led_desc {
- gpio_reg_t reg; /* LED register address */
- u8 iv_shift; /* shift amount for input bit */
- u8 mode_shift; /* shift amount for mode bits */
+ void __iomem *reg; /* LED register address */
+ u8 iv_shift; /* shift amount for input bit */
+ u8 mode_shift; /* shift amount for mode bits */
};
-#define LED_DESC(_port,_led) { \
- .reg = GPIO_REG(SWITCH_REG_PORT0_LED+_port*4), \
- .iv_shift = LED0_IV_SHIFT+_led, \
- .mode_shift = _led*4 \
+#define LED_DESC(p, l) { \
+ .reg = GPIO_REG(SWITCH_REG_PORT0_LED+((p) * 4)), \
+ .iv_shift = LED0_IV_SHIFT + (l), \
+ .mode_shift = (l) * 4 \
}
static struct led_desc led_table[15] = {
[ADM5120_GPIO_P4L2] = {.flags = GPIO_FLAG_VALID}
};
-#define gpio_is_invalid(g) ( \
- (g) > ADM5120_GPIO_MAX || \
- ((adm5120_gpio_map[(g)].flags & GPIO_FLAG_VALID) == 0) \
- )
+#define gpio_is_invalid(g) ((g) > ADM5120_GPIO_MAX || \
+ ((adm5120_gpio_map[(g)].flags & GPIO_FLAG_VALID) == 0))
#define gpio_is_used(g) ((adm5120_gpio_map[(g)].flags & GPIO_FLAG_USED) != 0)
static inline int pins_direction_input(unsigned pin)
{
- gpio_reg_t *reg;
+ void __iomem **reg;
u32 t;
reg = GPIO_REG(SWITCH_REG_GPIO_CONF0);
t = GPIO_READ(reg);
t &= ~(PIN_OE(pin));
t |= PIN_IM(pin);
- GPIO_WRITE(t,reg);
+ GPIO_WRITE(t, reg);
return 0;
}
static inline int pins_direction_output(unsigned pin, int value)
{
- gpio_reg_t *reg;
+ void __iomem **reg;
u32 t;
reg = GPIO_REG(SWITCH_REG_GPIO_CONF0);
if (value)
t |= PIN_OV(pin);
- GPIO_WRITE(t,reg);
+ GPIO_WRITE(t, reg);
return 0;
}
static inline int pins_get_value(unsigned pin)
{
- gpio_reg_t *reg;
+ void __iomem **reg;
u32 t;
reg = GPIO_REG(SWITCH_REG_GPIO_CONF0);
static inline void pins_set_value(unsigned pin, int value)
{
- gpio_reg_t *reg;
+ void __iomem **reg;
u32 t;
reg = GPIO_REG(SWITCH_REG_GPIO_CONF0);
else
t |= PIN_OV(pin);
- GPIO_WRITE(t,reg);
+ GPIO_WRITE(t, reg);
}
/*
*/
static inline int leds_direction_input(unsigned led)
{
- gpio_reg_t *reg;
+ void __iomem **reg;
u32 t;
reg = led_table[led].reg;
t = GPIO_READ(reg);
t &= ~(LED_MODE_MASK << led_table[led].mode_shift);
- GPIO_WRITE(t,reg);
+ GPIO_WRITE(t, reg);
return 0;
}
static inline int leds_direction_output(unsigned led, int value)
{
- gpio_reg_t *reg;
+ void __iomem **reg;
u32 t, s;
reg = led_table[led].reg;
break;
}
- GPIO_WRITE(t,reg);
+ GPIO_WRITE(t, reg);
return 0;
}
static inline int leds_get_value(unsigned led)
{
- gpio_reg_t *reg;
+ void __iomem **reg;
u32 t, m;
reg = led_table[led].reg;
gpio -= ADM5120_GPIO_P0L0;
return leds_direction_input(gpio);
}
+EXPORT_SYMBOL(adm5120_gpio_direction_input);
int adm5120_gpio_direction_output(unsigned gpio, int value)
{
gpio -= ADM5120_GPIO_P0L0;
return leds_direction_output(gpio, value);
}
+EXPORT_SYMBOL(adm5120_gpio_direction_output);
int adm5120_gpio_get_value(unsigned gpio)
{
gpio -= ADM5120_GPIO_P0L0;
return leds_get_value(gpio);
}
+EXPORT_SYMBOL(adm5120_gpio_get_value);
void adm5120_gpio_set_value(unsigned gpio, int value)
{
gpio -= ADM5120_GPIO_P0L0;
leds_direction_output(gpio, value);
}
+EXPORT_SYMBOL(adm5120_gpio_set_value);
int adm5120_gpio_request(unsigned gpio, const char *label)
{
return 0;
}
+EXPORT_SYMBOL(adm5120_gpio_request);
void adm5120_gpio_free(unsigned gpio)
{
adm5120_gpio_map[gpio].flags &= ~GPIO_FLAG_USED;
adm5120_gpio_map[gpio].label = NULL;
}
+EXPORT_SYMBOL(adm5120_gpio_free);
int adm5120_gpio_to_irq(unsigned gpio)
{
/* FIXME: not yet implemented */
return -EINVAL;
}
+EXPORT_SYMBOL(adm5120_gpio_to_irq);
int adm5120_irq_to_gpio(unsigned irq)
{
/* FIXME: not yet implemented */
return -EINVAL;
}
+EXPORT_SYMBOL(adm5120_irq_to_gpio);
static int __init adm5120_gpio_init(void)
{
if (adm5120_package_pqfp()) {
/* GPIO pins 4-7 are unavailable in ADM5120P */
- for (i=ADM5120_GPIO_PIN4; i<=ADM5120_GPIO_PIN7; i++)
+ for (i = ADM5120_GPIO_PIN4; i <= ADM5120_GPIO_PIN7; i++)
adm5120_gpio_map[i].flags &= ~GPIO_FLAG_VALID;
}
}
pure_initcall(adm5120_gpio_init);
-
-EXPORT_SYMBOL(adm5120_gpio_direction_output);
-EXPORT_SYMBOL(adm5120_gpio_direction_input);
-EXPORT_SYMBOL(adm5120_gpio_get_value);
-EXPORT_SYMBOL(adm5120_gpio_set_value);
-EXPORT_SYMBOL(adm5120_gpio_request);
-EXPORT_SYMBOL(adm5120_gpio_free);
-EXPORT_SYMBOL(adm5120_gpio_to_irq);
-EXPORT_SYMBOL(adm5120_irq_to_gpio);
#include <linux/interrupt.h>
#include <linux/ioport.h>
-#include <asm/io.h>
+#include <linux/io.h>
#include <asm/irq.h>
#include <asm/irq_cpu.h>
#include <asm/mipsregs.h>
#include <asm/bitops.h>
-#include <asm/mach-adm5120/adm5120_defs.h>
-#include <asm/mach-adm5120/adm5120_irq.h>
+#include <adm5120_defs.h>
+#include <adm5120_irq.h>
#define INTC_WRITE(reg, val) __raw_writel((val), \
(void __iomem *)(KSEG1ADDR(ADM5120_INTC_BASE) + reg))
-#define INTC_READ(reg) __raw_readl( \
+#define INTC_READ(reg) __raw_readl(\
(void __iomem *)(KSEG1ADDR(ADM5120_INTC_BASE) + reg))
static void adm5120_intc_irq_unmask(unsigned int irq);
/* disable usage of the TEST_SOURCE register */
INTC_WRITE(INTC_REG_IRQ_SOURCE_SELECT, 0);
- for (i = ADM5120_INTC_IRQ_BASE; i <= ADM5120_INTC_IRQ_BASE+INTC_IRQ_LAST;
+ for (i = ADM5120_INTC_IRQ_BASE;
+ i <= ADM5120_INTC_IRQ_BASE+INTC_IRQ_LAST;
i++) {
irq_desc[i].status = INTC_IRQ_STATUS;
set_irq_chip_and_handler(i, &adm5120_intc_irq_chip,
#include <linux/init.h>
#include <linux/types.h>
#include <linux/kernel.h>
+#include <linux/io.h>
-#include <asm/io.h>
#include <asm/bootinfo.h>
#include <asm/addrspace.h>
#include <adm5120_switch.h>
#include <adm5120_mpmc.h>
-#if 1
-# define mem_dbg(f, a...) printk("mem_detect: " f, ## a)
+#ifdef DEBUG
+# define mem_dbg(f, a...) printk(KERN_INFO "mem_detect: " f, ## a)
#else
# define mem_dbg(f, a...)
#endif
{
u32 *p1 = (u32 *)addr;
u32 *p2 = (u32 *)(addr+offs);
- u32 t,u,v;
+ u32 t, u, v;
/* save original value */
t = MEM_READL(p1);
mem_dbg("check presence of 2nd bank\n");
p = (u8 *)KSEG1ADDR(maxsize+size-4);
- if (mem_check_pattern(p, 0)) {
+ if (mem_check_pattern(p, 0))
adm5120_memsize += size;
- }
if (maxsize != size) {
/* adjusting MECTRL register */
out:
mem_dbg("%dx%uMB memory found\n", (adm5120_memsize == size) ? 1 : 2 ,
- size >>20);
+ size>>20);
}
void __init adm5120_mem_init(void)
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/mm.h>
+#include <linux/io.h>
-#include <asm/io.h>
#include <asm/bootinfo.h>
#include <asm/addrspace.h>
#define DEFBOARD(n, mt) { .mach_type = (mt), .name = (n)}
static struct board_desc common_boards[] __initdata = {
/* Cellvision/SparkLAN boards */
- DEFBOARD("CAS-630", MACH_ADM5120_CAS630),
- DEFBOARD("CAS-670", MACH_ADM5120_CAS670),
- DEFBOARD("CAS-771", MACH_ADM5120_CAS771),
- DEFBOARD("CAS-790", MACH_ADM5120_CAS790),
- DEFBOARD("CAS-861", MACH_ADM5120_CAS861),
+ DEFBOARD("CAS-630", MACH_ADM5120_CAS630),
+ DEFBOARD("CAS-670", MACH_ADM5120_CAS670),
+ DEFBOARD("CAS-771", MACH_ADM5120_CAS771),
+ DEFBOARD("CAS-790", MACH_ADM5120_CAS790),
+ DEFBOARD("CAS-861", MACH_ADM5120_CAS861),
/* Compex boards */
- DEFBOARD("WP54G-WRT", MACH_ADM5120_WP54G_WRT),
+ DEFBOARD("WP54G-WRT", MACH_ADM5120_WP54G_WRT),
/* Edimax boards */
- DEFBOARD("BR-6104K", MACH_ADM5120_BR6104K),
- DEFBOARD("BR-6104KP", MACH_ADM5120_BR6104K),
+ DEFBOARD("BR-6104K", MACH_ADM5120_BR6104K),
+ DEFBOARD("BR-6104KP", MACH_ADM5120_BR6104K),
/* Infineon boards */
DEFBOARD("EASY 5120P-ATA", MACH_ADM5120_EASY5120PATA),
DEFBOARD("EASY 5120-RT", MACH_ADM5120_EASY5120RT),
DEFBOARD("EASY 5120-WVoIP", MACH_ADM5120_EASY5120WVOIP),
DEFBOARD("EASY 83000", MACH_ADM5120_EASY83000),
/* Mikrotik RouterBOARDs */
- DEFBOARD("111", MACH_ADM5120_RB_111),
- DEFBOARD("112", MACH_ADM5120_RB_112),
- DEFBOARD("133", MACH_ADM5120_RB_133),
- DEFBOARD("133C", MACH_ADM5120_RB_133C),
- DEFBOARD("133C3", MACH_ADM5120_RB_133C),
- DEFBOARD("150", MACH_ADM5120_RB_153), /* it's intentional */
- DEFBOARD("153", MACH_ADM5120_RB_153),
- DEFBOARD("192", MACH_ADM5120_RB_192),
- DEFBOARD("miniROUTER", MACH_ADM5120_RB_150),
+ DEFBOARD("111", MACH_ADM5120_RB_111),
+ DEFBOARD("112", MACH_ADM5120_RB_112),
+ DEFBOARD("133", MACH_ADM5120_RB_133),
+ DEFBOARD("133C", MACH_ADM5120_RB_133C),
+ DEFBOARD("133C3", MACH_ADM5120_RB_133C),
+ DEFBOARD("150", MACH_ADM5120_RB_153), /* it's intentional */
+ DEFBOARD("153", MACH_ADM5120_RB_153),
+ DEFBOARD("192", MACH_ADM5120_RB_192),
+ DEFBOARD("miniROUTER", MACH_ADM5120_RB_150),
};
static unsigned long __init find_machtype_byname(char *name)
if (*name == '\0')
goto out;
- for (i=0; i<ARRAY_SIZE(common_boards); i++) {
+ for (i = 0; i < ARRAY_SIZE(common_boards); i++) {
if (strcmp(common_boards[i].name, name) == 0) {
ret = common_boards[i].mach_type;
break;
u16 vendor_id;
u16 board_id;
} zynos_boards[] __initdata = {
-#define ZYNOS_BOARD(vi, bi, mt) { .vendor_id = (vi), .board_id = (bi), \
- .mach_type = (mt) }
+#define ZYNOS_BOARD(vi, bi, mt) \
+ {.vendor_id = (vi), .board_id = (bi), .mach_type = (mt)}
#define ZYXEL_BOARD(bi, mt) ZYNOS_BOARD(ZYNOS_VENDOR_ID_ZYXEL, bi, mt)
#define DLINK_BOARD(bi, mt) ZYNOS_BOARD(ZYNOS_VENDOR_ID_DLINK, bi, mt)
int i;
ret = MACH_ADM5120_GENERIC;
- for (i=0; i<ARRAY_SIZE(zynos_boards); i++) {
+ for (i = 0; i < ARRAY_SIZE(zynos_boards); i++) {
if (zynos_boards[i].vendor_id == bootbase_info.vendor_id &&
zynos_boards[i].board_id == bootbase_info.board_id) {
ret = zynos_boards[i].mach_type;
u16 svid;
u16 sdid;
} mylo_boards[] __initdata = {
-#define MYLO_BOARD(v,d,sv,sd,mt) { .vid = (v), .did = (d), .svid = (sv), \
- .sdid = (sd), .mach_type = (mt) }
-#define COMPEX_BOARD(d,mt) MYLO_BOARD(VENID_COMPEX,(d),VENID_COMPEX,(d),(mt))
+#define MYLO_BOARD(v, d, sv, sd, mt) \
+ {.vid = (v), .did = (d), .svid = (sv), .sdid = (sd), .mach_type = (mt)}
+#define COMPEX_BOARD(d, mt) \
+ MYLO_BOARD(VENID_COMPEX, (d), VENID_COMPEX, (d), (mt))
COMPEX_BOARD(DEVID_COMPEX_NP27G, MACH_ADM5120_NP27G),
COMPEX_BOARD(DEVID_COMPEX_NP28G, MACH_ADM5120_NP28G),
int i;
ret = MACH_ADM5120_GENERIC;
- for (i=0; i<ARRAY_SIZE(mylo_boards); i++) {
+ for (i = 0; i < ARRAY_SIZE(mylo_boards); i++) {
if (mylo_boards[i].vid == myloader_info.vid &&
mylo_boards[i].did == myloader_info.did &&
mylo_boards[i].svid == myloader_info.svid &&
/* init command line, register a default kernel command line */
cmd = &_image_cmdline + 8;
- if( strlen(cmd) > 0) strcpy( &(arcs_cmdline[0]), cmd);
- else strcpy(&(arcs_cmdline[0]), CONFIG_CMDLINE);
+ if (strlen(cmd) > 0)
+ strcpy(arcs_cmdline, cmd);
+ else
+ strcpy(arcs_cmdline, CONFIG_CMDLINE);
}
#define BOOTEXT_ADDR_MIN KSEG1ADDR(ADM5120_SRAM0_BASE)
#define BOOTEXT_ADDR_MAX (BOOTEXT_ADDR_MIN + (2*1024*1024))
-static int bootbase_found = 0;
+static int bootbase_found;
static struct zynos_board_info *board_info;
struct bootbase_info bootbase_info;
static inline u16 bootbase_get_vendor_id(void)
{
-#define CHECK_VENDOR(n) (strnicmp(board_info->vendor,(n),strlen(n)) == 0)
+#define CHECK_VENDOR(n) (strnicmp(board_info->vendor, (n), strlen(n)) == 0)
unsigned char vendor[ZYNOS_NAME_LEN];
int i;
- for (i=0; i<ZYNOS_NAME_LEN; i++)
- vendor[i]=board_info->vendor[i];
+ for (i = 0; i < ZYNOS_NAME_LEN; i++)
+ vendor[i] = board_info->vendor[i];
if CHECK_VENDOR(ZYNOS_VENDOR_ZYXEL)
return ZYNOS_VENDOR_ID_ZYXEL;
#define CFE_EPTSEAL 0x43464531 /* CFE1 is the magic number to recognize CFE
from other bootloaders */
-static int cfe_found = 0;
+static int cfe_found;
static u32 cfe_handle;
static u32 cfe_entry;
cfe_seal = (u32) fw_arg3;
/* Check for CFE by finding the CFE magic number */
- if (cfe_seal != CFE_EPTSEAL) {
- /* We are not booted from CFE */
+ if (cfe_seal != CFE_EPTSEAL)
return 0;
- }
/* cfe_a1_val must be 0, because only one CPU present in the ADM5120 */
- if (a1 != 0) {
+ if (a1 != 0)
return 0;
- }
/* The cfe_handle, and the cfe_entry must be kernel mode addresses */
- if ((cfe_handle < KSEG0) || (cfe_entry < KSEG0)) {
+ if ((cfe_handle < KSEG0) || (cfe_entry < KSEG0))
return 0;
- }
cfe_found = 1;
return 1;
#define BOARD_PARAMS_ADDR KSEG1ADDR(ADM5120_SRAM0_BASE+0x0F800)
#define PART_TABLE_ADDR KSEG1ADDR(ADM5120_SRAM0_BASE+0x10000)
-static int myloader_found = 0;
+static int myloader_found;
struct myloader_info myloader_info;
#include "prom_read.h"
static struct rb_hard_settings rb_hs;
-static int rb_found = 0;
+static int rb_found;
static int __init routerboot_load_hs(u8 *buf, u16 buflen)
{
- u16 id,len;
+ u16 id, len;
u8 *mac;
- int i,j;
+ int i, j;
memset(&rb_hs, 0, sizeof(rb_hs));
if (rb_hs.mac_count > RB_MAX_MAC_COUNT)
rb_hs.mac_count = RB_MAX_MAC_COUNT;
mac = buf;
- for (i=0; i < rb_hs.mac_count; i++) {
- for (j=0; j < RB_MAC_SIZE; j++)
+ for (i = 0; i < rb_hs.mac_count; i++) {
+ for (j = 0; j < RB_MAC_SIZE; j++)
rb_hs.macs[i][j] = mac[j];
mac += RB_MAC_SIZE;
}
{
struct rb_bios_settings *bs;
u8 *base;
- u32 off,len;
+ u32 off, len;
if (rb_found)
goto out;
#include <linux/kernel.h>
#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/io.h>
+
#include <asm/bootinfo.h>
#include <asm/addrspace.h>
-#include <asm/mach-adm5120/adm5120_info.h>
-#include <asm/mach-adm5120/adm5120_defs.h>
-#include <asm/mach-adm5120/adm5120_switch.h>
-
-#define ADM5120_SOFTRESET 0x12000004
+#include <adm5120_info.h>
+#include <adm5120_defs.h>
+#include <adm5120_switch.h>
void (*adm5120_board_reset)(void);
if (adm5120_board_reset)
adm5120_board_reset();
- *(u32*)KSEG1ADDR(ADM5120_SOFTRESET)=1;
+ SW_WRITE_REG(SOFT_RESET, 1);
}
void adm5120_halt(void)
{
- printk(KERN_NOTICE "\n** You can safely turn off the power\n");
- while (1);
-}
+ local_irq_disable();
-void adm5120_power_off(void)
-{
- adm5120_halt();
+ printk(KERN_NOTICE "\n** You can safely turn off the power\n");
+ while (1) {
+ if (cpu_wait)
+ cpu_wait();
+ };
}
#include <linux/init.h>
#include <linux/kernel.h>
+#include <linux/io.h>
#include <asm/reboot.h>
-#include <asm/io.h>
#include <asm/time.h>
-#include <asm/mach-adm5120/adm5120_info.h>
-#include <asm/mach-adm5120/adm5120_defs.h>
-#include <asm/mach-adm5120/adm5120_switch.h>
-#include <asm/mach-adm5120/adm5120_board.h>
+#include <adm5120_info.h>
+#include <adm5120_defs.h>
+#include <adm5120_switch.h>
+#include <adm5120_board.h>
static char *prom_names[ADM5120_PROM_LAST+1] __initdata = {
[ADM5120_PROM_GENERIC] = "Generic",
static void __init adm5120_report(void)
{
- printk(KERN_INFO "SoC : ADM%04X%s revision %d, running at %ldMHz\n",
+ printk(KERN_INFO "SoC : ADM%04X%s revision %d, running "
+ "at %ldMHz\n",
adm5120_product_code,
- (adm5120_package == ADM5120_PACKAGE_BGA) ? "" : "P",
- adm5120_revision, (adm5120_speed / 1000000)
- );
- printk(KERN_INFO "Bootdev : %s flash\n", adm5120_nand_boot ? "NAND":"NOR");
+ adm5120_package_bga() ? "" : "P",
+ adm5120_revision, (adm5120_speed / 1000000));
+ printk(KERN_INFO "Bootdev : %s flash\n",
+ adm5120_nand_boot ? "NAND":"NOR");
printk(KERN_INFO "Prom : %s\n", prom_names[adm5120_prom_type]);
}
_machine_restart = adm5120_restart;
_machine_halt = adm5120_halt;
- pm_power_off = adm5120_power_off;
+ pm_power_off = adm5120_halt;
set_io_port_base(KSEG1);
}
#include <asm/cpu.h>
#include <asm/time.h>
-#include <asm/mach-adm5120/adm5120_info.h>
-#include <asm/mach-adm5120/adm5120_irq.h>
+#include <adm5120_info.h>
+#include <adm5120_irq.h>
void __init adm5120_time_init(void)
{
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/spinlock.h>
+#include <linux/io.h>
#include <linux/pci.h>
#include <linux/pci_ids.h>
#include <linux/pci_regs.h>
-#include <asm/io.h>
#include <asm/delay.h>
#include <asm/bootinfo.h>
#undef DEBUG
#ifdef DEBUG
-#define DBG(f, a...) printk(KERN_DEBUG f, ## a )
+#define DBG(f, a...) printk(KERN_DEBUG f, ## a)
#else
#define DBG(f, a...) do {} while (0)
#endif
/* -------------------------------------------------------------------------*/
-static unsigned int adm5120_pci_nr_irqs __initdata = 0;
-static struct adm5120_pci_irq *adm5120_pci_irq_map __initdata = NULL;
+static unsigned int adm5120_pci_nr_irqs __initdata;
+static struct adm5120_pci_irq *adm5120_pci_irq_map __initdata;
static spinlock_t pci_lock = SPIN_LOCK_UNLOCKED;
spin_lock_irqsave(&pci_lock, flags);
- write_cfgaddr(mkaddr(bus,devfn,where));
+ write_cfgaddr(mkaddr(bus, devfn, where));
data = read_cfgdata();
DBG("PCI: cfg_read %02u.%02u.%01u/%02X:%01d, cfg:0x%08X",
spin_lock_irqsave(&pci_lock, flags);
- write_cfgaddr(mkaddr(bus,devfn,where));
+ write_cfgaddr(mkaddr(bus, devfn, where));
data = read_cfgdata();
DBG("PCI: cfg_write %02u.%02u.%01u/%02X:%01d, cfg:0x%08X",
if (irq < 0) {
printk(KERN_ALERT "PCI: no irq found for %s pin:%u\n",
- pci_name(dev), pin);
+ pci_name((struct pci_dev *)dev), pin);
} else {
printk(KERN_INFO "PCI: mapping irq for %s pin:%u, irq:%d\n",
- pci_name(dev), pin, irq);
+ pci_name((struct pci_dev *)dev), pin, irq);
}
out:
struct gpio_led_platform_data pdata;
};
-static int led_count = 0;
+static int led_count;
static struct adm5120_leddev *led_devs[NUM_LEDS_MAX];
#define LED_ARRAY(n) \
static struct gpio_led n ## _leds [] __initdata =
-#define LED_DATA(n,t,g,al) { \
- .name = (n), \
- .default_trigger = (t), \
- .gpio = (g), \
- .active_low = (al) \
- }
+#define LED_DATA(n, t, g, a) { \
+ .name = (n), \
+ .default_trigger = (t), \
+ .gpio = (g), \
+ .active_low = (a) \
+}
-#define LED_STD(g,n,t) LED_DATA((n),(t),(g), 0)
-#define LED_INV(g,n,t) LED_DATA((n),(t),(g), 1)
+#define LED_STD(g, n, t) LED_DATA((n), (t), (g), 0)
+#define LED_INV(g, n, t) LED_DATA((n), (t), (g), 1)
/*
* Compex boards
*/
#if defined(CONFIG_LEDS_ADM5120_EXPERIMENTAL)
LED_ARRAY(np27g) { /* FIXME: untested */
- LED_STD(ADM5120_GPIO_xxxx, "lan1", NULL ),
- LED_STD(ADM5120_GPIO_xxxx, "lan2", NULL ),
- LED_STD(ADM5120_GPIO_xxxx, "lan3", NULL ),
- LED_STD(ADM5120_GPIO_xxxx, "lan4", NULL ),
- LED_STD(ADM5120_GPIO_xxxx, "wan_cond", NULL ),
- LED_STD(ADM5120_GPIO_xxxx, "wlan", NULL ),
- LED_STD(ADM5120_GPIO_xxxx, "wan_act", NULL ),
- LED_STD(ADM5120_GPIO_xxxx, "usb1", NULL ),
- LED_STD(ADM5120_GPIO_xxxx, "usb2", NULL ),
- LED_INV(ADM5120_GPIO_PIN2, "power", NULL ),
- LED_STD(ADM5120_GPIO_xxxx, "diag", NULL ),
+ LED_STD(ADM5120_GPIO_xxxx, "lan1", NULL),
+ LED_STD(ADM5120_GPIO_xxxx, "lan2", NULL),
+ LED_STD(ADM5120_GPIO_xxxx, "lan3", NULL),
+ LED_STD(ADM5120_GPIO_xxxx, "lan4", NULL),
+ LED_STD(ADM5120_GPIO_xxxx, "wan_cond", NULL),
+ LED_STD(ADM5120_GPIO_xxxx, "wlan", NULL),
+ LED_STD(ADM5120_GPIO_xxxx, "wan_act", NULL),
+ LED_STD(ADM5120_GPIO_xxxx, "usb1", NULL),
+ LED_STD(ADM5120_GPIO_xxxx, "usb2", NULL),
+ LED_INV(ADM5120_GPIO_PIN2, "power", NULL),
+ LED_STD(ADM5120_GPIO_xxxx, "diag", NULL),
};
#endif
#if defined(CONFIG_LEDS_ADM5120_EXPERIMENTAL)
LED_ARRAY(np28g) { /* FIXME: untested */
- LED_STD(ADM5120_GPIO_xxxx, "lan1", NULL ),
- LED_STD(ADM5120_GPIO_xxxx, "lan2", NULL ),
- LED_STD(ADM5120_GPIO_xxxx, "lan3", NULL ),
- LED_STD(ADM5120_GPIO_xxxx, "wan", NULL ),
- LED_STD(ADM5120_GPIO_xxxx, "wlan", NULL ),
- LED_STD(ADM5120_GPIO_xxxx, "usb1", NULL ),
- LED_STD(ADM5120_GPIO_xxxx, "usb2", NULL ),
- LED_STD(ADM5120_GPIO_xxxx, "usb3", NULL ),
- LED_STD(ADM5120_GPIO_xxxx, "usb4", NULL ),
- LED_INV(ADM5120_GPIO_PIN2, "power", NULL ),
- LED_STD(ADM5120_GPIO_xxxx, "diag", NULL ),
+ LED_STD(ADM5120_GPIO_xxxx, "lan1", NULL),
+ LED_STD(ADM5120_GPIO_xxxx, "lan2", NULL),
+ LED_STD(ADM5120_GPIO_xxxx, "lan3", NULL),
+ LED_STD(ADM5120_GPIO_xxxx, "wan", NULL),
+ LED_STD(ADM5120_GPIO_xxxx, "wlan", NULL),
+ LED_STD(ADM5120_GPIO_xxxx, "usb1", NULL),
+ LED_STD(ADM5120_GPIO_xxxx, "usb2", NULL),
+ LED_STD(ADM5120_GPIO_xxxx, "usb3", NULL),
+ LED_STD(ADM5120_GPIO_xxxx, "usb4", NULL),
+ LED_INV(ADM5120_GPIO_PIN2, "power", NULL),
+ LED_STD(ADM5120_GPIO_xxxx, "diag", NULL),
};
#endif
LED_ARRAY(wp54g) {
- LED_INV(ADM5120_GPIO_PIN2, "diag", NULL ),
- LED_INV(ADM5120_GPIO_PIN6, "wlan", NULL ),
- LED_INV(ADM5120_GPIO_PIN7, "wan", NULL ),
- LED_INV(ADM5120_GPIO_P0L0, "lan1", NULL ),
- LED_INV(ADM5120_GPIO_P1L0, "lan2", NULL ),
+ LED_INV(ADM5120_GPIO_PIN2, "diag", NULL),
+ LED_INV(ADM5120_GPIO_PIN6, "wlan", NULL),
+ LED_INV(ADM5120_GPIO_PIN7, "wan", NULL),
+ LED_INV(ADM5120_GPIO_P0L0, "lan1", NULL),
+ LED_INV(ADM5120_GPIO_P1L0, "lan2", NULL),
};
/*
* Edimax boards
*/
LED_ARRAY(br6104k) {
- LED_STD(ADM5120_GPIO_PIN0, "power", NULL ),
- LED_INV(ADM5120_GPIO_P0L1, "wan_speed", NULL ),
- LED_INV(ADM5120_GPIO_P0L0, "wan_lnkact", NULL ),
- LED_INV(ADM5120_GPIO_P1L1, "lan1_speed", NULL ),
- LED_INV(ADM5120_GPIO_P1L0, "lan1_lnkact", NULL ),
- LED_INV(ADM5120_GPIO_P2L1, "lan2_speed", NULL ),
- LED_INV(ADM5120_GPIO_P2L0, "lan2_lnkact", NULL ),
- LED_INV(ADM5120_GPIO_P3L1, "lan3_speed", NULL ),
- LED_INV(ADM5120_GPIO_P3L0, "lan3_lnkact", NULL ),
- LED_INV(ADM5120_GPIO_P4L1, "lan4_speed", NULL ),
- LED_INV(ADM5120_GPIO_P4L0, "lan4_lnkact", NULL ),
+ LED_STD(ADM5120_GPIO_PIN0, "power", NULL),
+ LED_INV(ADM5120_GPIO_P0L1, "wan_speed", NULL),
+ LED_INV(ADM5120_GPIO_P0L0, "wan_lnkact", NULL),
+ LED_INV(ADM5120_GPIO_P1L1, "lan1_speed", NULL),
+ LED_INV(ADM5120_GPIO_P1L0, "lan1_lnkact", NULL),
+ LED_INV(ADM5120_GPIO_P2L1, "lan2_speed", NULL),
+ LED_INV(ADM5120_GPIO_P2L0, "lan2_lnkact", NULL),
+ LED_INV(ADM5120_GPIO_P3L1, "lan3_speed", NULL),
+ LED_INV(ADM5120_GPIO_P3L0, "lan3_lnkact", NULL),
+ LED_INV(ADM5120_GPIO_P4L1, "lan4_speed", NULL),
+ LED_INV(ADM5120_GPIO_P4L0, "lan4_lnkact", NULL),
};
/*
*/
#if defined(CONFIG_LEDS_ADM5120_EXPERIMENTAL)
LED_ARRAY(rb100) { /* FIXME: untested */
- LED_STD(ADM5120_GPIO_PIN6, "power", NULL ),
- LED_STD(ADM5120_GPIO_PIN3, "user", NULL ),
+ LED_STD(ADM5120_GPIO_PIN6, "power", NULL),
+ LED_STD(ADM5120_GPIO_PIN3, "user", NULL),
};
#endif
LED_ARRAY(rb133) {
- LED_STD(ADM5120_GPIO_PIN6, "power", NULL ),
- LED_STD(ADM5120_GPIO_PIN5, "user", NULL ),
+ LED_STD(ADM5120_GPIO_PIN6, "power", NULL),
+ LED_STD(ADM5120_GPIO_PIN5, "user", NULL),
};
/*
*/
#if defined(CONFIG_LEDS_ADM5120_EXPERIMENTAL)
LED_ARRAY(p334) { /* FIXME: untested */
- LED_INV(ADM5120_GPIO_xxxx, "power", NULL ),
- LED_INV(ADM5120_GPIO_xxxx, "lan1", NULL ),
- LED_INV(ADM5120_GPIO_xxxx, "lan2", NULL ),
- LED_INV(ADM5120_GPIO_xxxx, "lan3", NULL ),
- LED_INV(ADM5120_GPIO_xxxx, "lan4", NULL ),
- LED_INV(ADM5120_GPIO_xxxx, "wan", NULL ),
+ LED_INV(ADM5120_GPIO_xxxx, "power", NULL),
+ LED_INV(ADM5120_GPIO_xxxx, "lan1", NULL),
+ LED_INV(ADM5120_GPIO_xxxx, "lan2", NULL),
+ LED_INV(ADM5120_GPIO_xxxx, "lan3", NULL),
+ LED_INV(ADM5120_GPIO_xxxx, "lan4", NULL),
+ LED_INV(ADM5120_GPIO_xxxx, "wan", NULL),
};
#endif
LED_ARRAY(p334wt) {
- LED_INV(ADM5120_GPIO_PIN2, "power", NULL ),
- LED_INV(ADM5120_GPIO_P3L0, "lan1", NULL ),
- LED_INV(ADM5120_GPIO_P2L0, "lan2", NULL ),
- LED_INV(ADM5120_GPIO_P1L0, "lan3", NULL ),
- LED_INV(ADM5120_GPIO_P0L0, "lan4", NULL ),
- LED_INV(ADM5120_GPIO_P4L0, "wan", NULL ),
- LED_INV(ADM5120_GPIO_P4L2, "wlan", NULL ),
- LED_INV(ADM5120_GPIO_P2L2, "otist", NULL ),
- LED_INV(ADM5120_GPIO_P1L2, "hidden", NULL ),
+ LED_INV(ADM5120_GPIO_PIN2, "power", NULL),
+ LED_INV(ADM5120_GPIO_P3L0, "lan1", NULL),
+ LED_INV(ADM5120_GPIO_P2L0, "lan2", NULL),
+ LED_INV(ADM5120_GPIO_P1L0, "lan3", NULL),
+ LED_INV(ADM5120_GPIO_P0L0, "lan4", NULL),
+ LED_INV(ADM5120_GPIO_P4L0, "wan", NULL),
+ LED_INV(ADM5120_GPIO_P4L2, "wlan", NULL),
+ LED_INV(ADM5120_GPIO_P2L2, "otist", NULL),
+ LED_INV(ADM5120_GPIO_P1L2, "hidden", NULL),
};
#if defined(CONFIG_LEDS_ADM5120_EXPERIMENTAL)
LED_ARRAY(p335) { /* FIXME: untested */
- LED_INV(ADM5120_GPIO_PIN2, "power", NULL ),
- LED_INV(ADM5120_GPIO_P3L0, "lan1", NULL ),
- LED_INV(ADM5120_GPIO_P2L0, "lan2", NULL ),
- LED_INV(ADM5120_GPIO_P1L0, "lan3", NULL ),
- LED_INV(ADM5120_GPIO_P0L0, "lan4", NULL ),
- LED_INV(ADM5120_GPIO_P4L0, "wan", NULL ),
- LED_INV(ADM5120_GPIO_P4L2, "wlan", NULL ),
- LED_INV(ADM5120_GPIO_P2L2, "otist", NULL ),
- LED_INV(ADM5120_GPIO_xxxx, "usb", NULL ),
+ LED_INV(ADM5120_GPIO_PIN2, "power", NULL),
+ LED_INV(ADM5120_GPIO_P3L0, "lan1", NULL),
+ LED_INV(ADM5120_GPIO_P2L0, "lan2", NULL),
+ LED_INV(ADM5120_GPIO_P1L0, "lan3", NULL),
+ LED_INV(ADM5120_GPIO_P0L0, "lan4", NULL),
+ LED_INV(ADM5120_GPIO_P4L0, "wan", NULL),
+ LED_INV(ADM5120_GPIO_P4L2, "wlan", NULL),
+ LED_INV(ADM5120_GPIO_P2L2, "otist", NULL),
+ LED_INV(ADM5120_GPIO_xxxx, "usb", NULL),
};
#endif
*/
LED_ARRAY(generic) {
#if defined(CONFIG_LEDS_ADM5120_DIAG)
- LED_STD(ADM5120_GPIO_PIN0, "gpio0", NULL ),
- LED_STD(ADM5120_GPIO_PIN1, "gpio1", NULL ),
- LED_STD(ADM5120_GPIO_PIN2, "gpio2", NULL ),
- LED_STD(ADM5120_GPIO_PIN3, "gpio3", NULL ),
- LED_STD(ADM5120_GPIO_PIN4, "gpio4", NULL ),
- LED_STD(ADM5120_GPIO_PIN5, "gpio5", NULL ),
- LED_STD(ADM5120_GPIO_PIN6, "gpio6", NULL ),
- LED_STD(ADM5120_GPIO_PIN7, "gpio7", NULL ),
- LED_STD(ADM5120_GPIO_P0L0, "port0led0", NULL ),
- LED_STD(ADM5120_GPIO_P0L1, "port0led1", NULL ),
- LED_STD(ADM5120_GPIO_P0L2, "port0led2", NULL ),
- LED_STD(ADM5120_GPIO_P1L0, "port1led0", NULL ),
- LED_STD(ADM5120_GPIO_P1L1, "port1led1", NULL ),
- LED_STD(ADM5120_GPIO_P1L2, "port1led2", NULL ),
- LED_STD(ADM5120_GPIO_P2L0, "port2led0", NULL ),
- LED_STD(ADM5120_GPIO_P2L1, "port2led1", NULL ),
- LED_STD(ADM5120_GPIO_P2L2, "port2led2", NULL ),
- LED_STD(ADM5120_GPIO_P3L0, "port3led0", NULL ),
- LED_STD(ADM5120_GPIO_P3L1, "port3led1", NULL ),
- LED_STD(ADM5120_GPIO_P3L2, "port3led2", NULL ),
- LED_STD(ADM5120_GPIO_P4L0, "port4led0", NULL ),
- LED_STD(ADM5120_GPIO_P4L1, "port4led1", NULL ),
- LED_STD(ADM5120_GPIO_P4L2, "port4led2", NULL ),
+ LED_STD(ADM5120_GPIO_PIN0, "gpio0", NULL),
+ LED_STD(ADM5120_GPIO_PIN1, "gpio1", NULL),
+ LED_STD(ADM5120_GPIO_PIN2, "gpio2", NULL),
+ LED_STD(ADM5120_GPIO_PIN3, "gpio3", NULL),
+ LED_STD(ADM5120_GPIO_PIN4, "gpio4", NULL),
+ LED_STD(ADM5120_GPIO_PIN5, "gpio5", NULL),
+ LED_STD(ADM5120_GPIO_PIN6, "gpio6", NULL),
+ LED_STD(ADM5120_GPIO_PIN7, "gpio7", NULL),
+ LED_STD(ADM5120_GPIO_P0L0, "port0led0", NULL),
+ LED_STD(ADM5120_GPIO_P0L1, "port0led1", NULL),
+ LED_STD(ADM5120_GPIO_P0L2, "port0led2", NULL),
+ LED_STD(ADM5120_GPIO_P1L0, "port1led0", NULL),
+ LED_STD(ADM5120_GPIO_P1L1, "port1led1", NULL),
+ LED_STD(ADM5120_GPIO_P1L2, "port1led2", NULL),
+ LED_STD(ADM5120_GPIO_P2L0, "port2led0", NULL),
+ LED_STD(ADM5120_GPIO_P2L1, "port2led1", NULL),
+ LED_STD(ADM5120_GPIO_P2L2, "port2led2", NULL),
+ LED_STD(ADM5120_GPIO_P3L0, "port3led0", NULL),
+ LED_STD(ADM5120_GPIO_P3L1, "port3led1", NULL),
+ LED_STD(ADM5120_GPIO_P3L2, "port3led2", NULL),
+ LED_STD(ADM5120_GPIO_P4L0, "port4led0", NULL),
+ LED_STD(ADM5120_GPIO_P4L1, "port4led1", NULL),
+ LED_STD(ADM5120_GPIO_P4L2, "port4led2", NULL),
#endif
};
-#define MACH_DATA(m, n) { \
+#define MACH_DATA(m, n) { \
.machtype = (m), \
.nr_leds = ARRAY_SIZE(n ## _leds), \
- .leds = n ## _leds \
+ .leds = n ## _leds \
}
static struct mach_data machines[] __initdata = {
p->pdev.name = "leds-gpio";
p->pdev.id = id;
p->pdev.dev.platform_data = &p->pdata;
- p->pdata.num_leds=1;
+ p->pdata.num_leds = 1;
p->pdata.leds = &p->led;
return p;
}
-static void
-destroy_leddev(struct adm5120_leddev *leddev)
-{
- if (leddev)
- kfree(leddev);
-}
-
static struct mach_data * __init
adm5120_leds_findmach(unsigned long machtype)
{
int i;
mach = NULL;
- for (i=0; i<ARRAY_SIZE(machines); i++) {
+ for (i = 0; i < ARRAY_SIZE(machines); i++) {
if (machines[i].machtype == machtype) {
mach = &machines[i];
break;
goto err;
}
- for (i=0; i < mach->nr_leds; i++) {
+ for (i = 0; i < mach->nr_leds; i++) {
led_devs[i] = create_leddev(i, &mach->leds[i]);
if (led_devs[i] == NULL) {
ret = -ENOMEM;
}
}
- for (i=0; i < mach->nr_leds; i++) {
+ for (i = 0; i < mach->nr_leds; i++) {
ret = platform_device_register(&led_devs[i]->pdev);
if (ret)
goto err_unregister;
return 0;
err_unregister:
- for (i--; i>=0; i--)
+ for (i--; i >= 0; i--)
platform_device_unregister(&led_devs[i]->pdev);
err_destroy:
- for (i=0; i<led_count; i++)
- destroy_leddev(led_devs[i]);
+ for (i = 0; i < led_count; i++)
+ kfree(led_devs[i]);
err:
return ret;
}
{
int i;
- for (i=0; i < led_count; i++) {
+ for (i = 0; i < led_count; i++) {
platform_device_unregister(&led_devs[i]->pdev);
- destroy_leddev(led_devs[i]);
+ kfree(led_devs[i]);
}
}
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/slab.h>
+#include <linux/io.h>
#include <linux/device.h>
-
#include <linux/platform_device.h>
+
#include <linux/mtd/mtd.h>
#include <linux/mtd/map.h>
#include <linux/mtd/partitions.h>
-#include <asm/io.h>
-
#include <adm5120_defs.h>
#include <adm5120_switch.h>
#include <adm5120_mpmc.h>
{
struct adm5120_map_info *amap = map_to_amap(map);
- MAP_DBG(map,"writing to ofs %lX\n", ofs);
+ MAP_DBG(map, "writing to ofs %lX\n", ofs);
if (ofs > amap->window_size)
return;
#ifdef CONFIG_MTD_PARTITIONS
static int adm5120_flash_initparts(struct adm5120_flash_info *info)
{
- struct adm5120_flash_platform_data *pdata = info->dev->dev.platform_data;
+ struct adm5120_flash_platform_data *pdata;
struct map_info *map = &info->amap.map;
int num_parsers;
const char *parser[2];
info->nr_parts = 0;
+ pdata = info->dev->dev.platform_data;
if (pdata == NULL)
goto out;
num_parsers = MAX_PARSED_PARTS;
parser[1] = NULL;
- for (i=0; i<num_parsers; i++) {
+ for (i = 0; i < num_parsers; i++) {
parser[0] = parse_types[i];
MAP_INFO(map, "parsing \"%s\" partitions\n",
if (info->nr_parts) {
del_mtd_partitions(info->mtd);
- for (i=0; i<MAX_PARSED_PARTS; i++)
+ for (i = 0; i < MAX_PARSED_PARTS; i++)
if (info->parts[i] != NULL)
kfree(info->parts[i]);
} else {
goto err_out;
if (info->nr_parts == 0) {
- MAP_INFO(map, "no partitions available, registering whole flash\n");
+ MAP_INFO(map, "no partitions available, registering "
+ "whole flash\n");
add_mtd_device(info->mtd);
}
}
#ifdef CONFIG_PM
-static int adm5120_flash_suspend(struct platform_device *dev, pm_message_t state)
+static int adm5120_flash_suspend(struct platform_device *dev,
+ pm_message_t state)
{
struct adm5120_flash_info *info = platform_get_drvdata(dev);
int ret = 0;
int num_parts;
int ret, i;
size_t retlen;
- size_t parts_len;
char *names;
unsigned long offset;
unsigned long blocklen;
num_parts++;
}
- mtd_parts = kzalloc((num_parts*sizeof(*mtd_part) + num_parts*NAME_LEN_MAX),
- GFP_KERNEL);
+ mtd_parts = kzalloc((num_parts * sizeof(*mtd_part) +
+ num_parts * NAME_LEN_MAX), GFP_KERNEL);
if (!mtd_parts) {
ret = -ENOMEM;
#define TRX_MAGIC 0x30524448 /* "HDR0" */
#define TRX_VERSION 1
#define TRX_MAX_LEN 0x3A0000
-#define TRX_NO_HEADER 1 /* Do not write TRX header */
-#define TRX_GZ_FILES 0x2 /* Contains up to TRX_MAX_OFFSET individual gzip files */
+#define TRX_NO_HEADER 0x1 /* do not write TRX header */
+#define TRX_GZ_FILES 0x2 /* contains individual gzip files */
#define TRX_MAX_OFFSET 3
#define TRX_MIN_KERNEL_SIZE 256*1024
struct trx_header {
- u32 magic; /* "HDR0" */
- u32 len; /* Length of file including header */
- u32 crc32; /* 32-bit CRC from flag_version to end of file */
- u32 flag_version; /* 0:15 flags, 16:31 version */
- u32 offsets[TRX_MAX_OFFSET]; /* Offsets of partitions from start of header */
+ u32 magic; /* "HDR0" */
+ u32 len; /* Length of file including header */
+ u32 crc32; /* 32-bit CRC from flag_version to end of file */
+ u32 flag_version; /* 0:15 flags, 16:31 version */
+ u32 offsets[TRX_MAX_OFFSET]; /* Offsets of partitions */
};
#define BLOCK_LEN_MIN 0x10000
-static struct mtd_info *trx_mtd = NULL;
-static unsigned long trx_offset = 0;
-static int trx_nr_parts = 0;
+static int trx_nr_parts;
+static unsigned long trx_offset;
+static struct mtd_info *trx_mtd;
static struct mtd_partition trx_parts[TRX_MAX_OFFSET];
static struct trx_header trx_hdr;
size_t retlen;
int err;
- err = mtd->read(mtd, offset, sizeof(trx_hdr), &retlen, (void *)&trx_hdr);
+ err = mtd->read(mtd, offset, sizeof(trx_hdr), &retlen,
+ (void *)&trx_hdr);
if (err) {
printk(KERN_ALERT PFX "unable to read from '%s'\n", mtd->name);
goto err_out;
printk(KERN_INFO PFX "searching TRX header in '%s'\n", mtd->name);
err = 0;
- for (offset=0; offset < mtd->size; offset+=blocklen) {
+ for (offset = 0; offset < mtd->size; offset += blocklen) {
err = trxsplit_checktrx(mtd, offset);
if (err == 0)
break;
int err;
int i;
- for (i=0; i<TRX_MAX_OFFSET;i++) {
+ for (i = 0; i < TRX_MAX_OFFSET; i++) {
part = &trx_parts[i];
if (trx_hdr.offsets[i] == 0)
continue;
trx_nr_parts++;
}
- for (i=0; i<trx_nr_parts-1; i++) {
+ for (i = 0; i < trx_nr_parts-1; i++)
trx_parts[i].size = trx_parts[i+1].offset - trx_parts[i].offset;
- }
+
trx_parts[i].size = mtd->size - trx_parts[i].offset;
- i=0;
+ i = 0;
part = &trx_parts[i];
if (part->size < TRX_MIN_KERNEL_SIZE) {
part->name = "loader";
trxsplit_scan();
if (trx_mtd) {
- printk(KERN_INFO PFX "creating TRX partitions in '%s' (%d,%d)\n",
- trx_mtd->name, MTD_BLOCK_MAJOR, trx_mtd->index);
+ printk(KERN_INFO PFX "creating TRX partitions in '%s' "
+ "(%d,%d)\n", trx_mtd->name, MTD_BLOCK_MAJOR,
+ trx_mtd->index);
trxsplit_create_partitions(trx_mtd);
}
extern void adm5120_restart(char *command);
extern void adm5120_halt(void);
-extern void adm5120_power_off(void);
extern void (*adm5120_board_reset)(void);