aboutsummaryrefslogtreecommitdiff
path: root/arch/mips/lasat
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/lasat')
-rw-r--r--arch/mips/lasat/Kconfig15
-rw-r--r--arch/mips/lasat/Makefile4
-rw-r--r--arch/mips/lasat/Platform7
-rw-r--r--arch/mips/lasat/at93c.c22
-rw-r--r--arch/mips/lasat/at93c.h4
-rw-r--r--arch/mips/lasat/ds1603.c38
-rw-r--r--arch/mips/lasat/ds1603.h10
-rw-r--r--arch/mips/lasat/image/Makefile17
-rw-r--r--arch/mips/lasat/image/head.S6
-rw-r--r--arch/mips/lasat/image/romscript.normal7
-rw-r--r--arch/mips/lasat/interrupt.c115
-rw-r--r--arch/mips/lasat/lasatIRQ.S69
-rw-r--r--arch/mips/lasat/lasat_board.c63
-rw-r--r--arch/mips/lasat/lasat_models.h76
-rw-r--r--arch/mips/lasat/picvue.c61
-rw-r--r--arch/mips/lasat/picvue.h24
-rw-r--r--arch/mips/lasat/picvue_proc.c146
-rw-r--r--arch/mips/lasat/prom.c95
-rw-r--r--arch/mips/lasat/prom.h13
-rw-r--r--arch/mips/lasat/reset.c19
-rw-r--r--arch/mips/lasat/serial.c93
-rw-r--r--arch/mips/lasat/setup.c97
-rw-r--r--arch/mips/lasat/sysctl.c361
-rw-r--r--arch/mips/lasat/sysctl.h24
24 files changed, 647 insertions, 739 deletions
diff --git a/arch/mips/lasat/Kconfig b/arch/mips/lasat/Kconfig
new file mode 100644
index 00000000000..1d2ee8a9be1
--- /dev/null
+++ b/arch/mips/lasat/Kconfig
@@ -0,0 +1,15 @@
+config PICVUE
+ tristate "PICVUE LCD display driver"
+ depends on LASAT
+
+config PICVUE_PROC
+ tristate "PICVUE LCD display driver /proc interface"
+ depends on PICVUE
+
+config DS1603
+ bool "DS1603 RTC driver"
+ depends on LASAT
+
+config LASAT_SYSCTL
+ bool "LASAT sysctl interface"
+ depends on LASAT
diff --git a/arch/mips/lasat/Makefile b/arch/mips/lasat/Makefile
index 0d5aec43672..869bd3b37c1 100644
--- a/arch/mips/lasat/Makefile
+++ b/arch/mips/lasat/Makefile
@@ -2,8 +2,8 @@
# Makefile for the LASAT specific kernel interface routines under Linux.
#
-obj-y += reset.o setup.o prom.o lasat_board.o \
- at93c.o interrupt.o lasatIRQ.o
+obj-y += reset.o setup.o prom.o lasat_board.o \
+ at93c.o interrupt.o serial.o
obj-$(CONFIG_LASAT_SYSCTL) += sysctl.o
obj-$(CONFIG_DS1603) += ds1603.o
diff --git a/arch/mips/lasat/Platform b/arch/mips/lasat/Platform
new file mode 100644
index 00000000000..760252828bf
--- /dev/null
+++ b/arch/mips/lasat/Platform
@@ -0,0 +1,7 @@
+#
+# LASAT platforms
+#
+platform-$(CONFIG_LASAT) += lasat/
+cflags-$(CONFIG_LASAT) += \
+ -I$(srctree)/arch/mips/include/asm/mach-lasat
+load-$(CONFIG_LASAT) += 0xffffffff80000000
diff --git a/arch/mips/lasat/at93c.c b/arch/mips/lasat/at93c.c
index f6add041ebe..942f32b91d1 100644
--- a/arch/mips/lasat/at93c.c
+++ b/arch/mips/lasat/at93c.c
@@ -1,14 +1,13 @@
-/*
+/*
* Atmel AT93C46 serial eeprom driver
*
- * Brian Murphy <brian.murphy@eicon.com>
+ * Brian Murphy <brian.murphy@eicon.com>
*
*/
#include <linux/kernel.h>
#include <linux/delay.h>
#include <asm/lasat/lasat.h>
#include <linux/module.h>
-#include <linux/init.h>
#include "at93c.h"
@@ -21,12 +20,12 @@
struct at93c_defs *at93c;
-static void at93c_reg_write(u32 val)
+static void at93c_reg_write(u32 val)
{
*at93c->reg = val;
}
-static u32 at93c_reg_read(void)
+static u32 at93c_reg_read(void)
{
u32 tmp = *at93c->reg;
return tmp;
@@ -73,7 +72,7 @@ static u8 at93c_read_byte(void)
int i;
u8 data = 0;
- for (i = 0; i<=7; i++) {
+ for (i = 0; i <= 7; i++) {
data <<= 1;
data |= at93c_read_databit();
}
@@ -81,7 +80,7 @@ static u8 at93c_read_byte(void)
}
static void at93c_write_bits(u32 data, int size)
-{
+{
int i;
int shift = size - 1;
u32 mask = (1 << shift);
@@ -90,11 +89,12 @@ static void at93c_write_bits(u32 data, int size)
at93c_write_databit((data & mask) >> shift);
data <<= 1;
}
-}
+}
static void at93c_init_op(void)
{
- at93c_reg_write((at93c_reg_read() | at93c->cs) & ~at93c->clk & ~(1 << at93c->rdata_shift));
+ at93c_reg_write((at93c_reg_read() | at93c->cs) &
+ ~at93c->clk & ~(1 << at93c->rdata_shift));
lasat_ndelay(50);
}
@@ -104,8 +104,8 @@ static void at93c_end_op(void)
lasat_ndelay(250);
}
-static void at93c_wait(void)
-{
+static void at93c_wait(void)
+{
at93c_init_op();
while (!at93c_read_databit())
;
diff --git a/arch/mips/lasat/at93c.h b/arch/mips/lasat/at93c.h
index a912ac2171b..cfe2f99b1d4 100644
--- a/arch/mips/lasat/at93c.h
+++ b/arch/mips/lasat/at93c.h
@@ -1,7 +1,7 @@
-/*
+/*
* Atmel AT93C46 serial eeprom driver
*
- * Brian Murphy <brian.murphy@eicon.com>
+ * Brian Murphy <brian.murphy@eicon.com>
*
*/
diff --git a/arch/mips/lasat/ds1603.c b/arch/mips/lasat/ds1603.c
index 7bbf6cf923c..c6fd96ff118 100644
--- a/arch/mips/lasat/ds1603.c
+++ b/arch/mips/lasat/ds1603.c
@@ -1,13 +1,14 @@
-/*
- * Dallas Semiconductors 1603 RTC driver
+/*
+ * Dallas Semiconductors 1603 RTC driver
*
- * Brian Murphy <brian@murphy.dk>
+ * Brian Murphy <brian@murphy.dk>
*
*/
#include <linux/kernel.h>
#include <asm/lasat/lasat.h>
#include <linux/delay.h>
#include <asm/lasat/ds1603.h>
+#include <asm/time.h>
#include "ds1603.h"
@@ -17,15 +18,15 @@
#define TRIMMER_VALUE_MASK 0x38
#define TRIMMER_SHIFT 3
-struct ds_defs *ds1603 = NULL;
+struct ds_defs *ds1603;
/* HW specific register functions */
-static void rtc_reg_write(unsigned long val)
+static void rtc_reg_write(unsigned long val)
{
*ds1603->reg = val;
}
-static unsigned long rtc_reg_read(void)
+static unsigned long rtc_reg_read(void)
{
unsigned long tmp = *ds1603->reg;
return tmp;
@@ -80,7 +81,7 @@ static unsigned int rtc_read_databit(void)
{
unsigned int data;
- data = (rtc_datareg_read() & (1 << ds1603->data_read_shift))
+ data = (rtc_datareg_read() & (1 << ds1603->data_read_shift))
>> ds1603->data_read_shift;
rtc_cycle_clock(rtc_reg_read());
return data;
@@ -90,7 +91,7 @@ static void rtc_write_byte(unsigned int byte)
{
int i;
- for (i = 0; i<=7; i++) {
+ for (i = 0; i <= 7; i++) {
rtc_write_databit(byte & 1L);
byte >>= 1;
}
@@ -100,7 +101,7 @@ static void rtc_write_word(unsigned long word)
{
int i;
- for (i = 0; i<=31; i++) {
+ for (i = 0; i <= 31; i++) {
rtc_write_databit(word & 1L);
word >>= 1;
}
@@ -112,7 +113,7 @@ static unsigned long rtc_read_word(void)
unsigned long word = 0;
unsigned long shift = 0;
- for (i = 0; i<=31; i++) {
+ for (i = 0; i <= 31; i++) {
word |= rtc_read_databit() << shift;
shift++;
}
@@ -134,23 +135,32 @@ static void rtc_end_op(void)
lasat_ndelay(1000);
}
-/* interface */
-unsigned long ds1603_read(void)
+void read_persistent_clock(struct timespec *ts)
{
unsigned long word;
+ unsigned long flags;
+
+ spin_lock_irqsave(&rtc_lock, flags);
rtc_init_op();
rtc_write_byte(READ_TIME_CMD);
word = rtc_read_word();
rtc_end_op();
- return word;
+ spin_unlock_irqrestore(&rtc_lock, flags);
+
+ ts->tv_sec = word;
+ ts->tv_nsec = 0;
}
-int ds1603_set(unsigned long time)
+int rtc_mips_set_mmss(unsigned long time)
{
+ unsigned long flags;
+
+ spin_lock_irqsave(&rtc_lock, flags);
rtc_init_op();
rtc_write_byte(SET_TIME_CMD);
rtc_write_word(time);
rtc_end_op();
+ spin_unlock_irqrestore(&rtc_lock, flags);
return 0;
}
diff --git a/arch/mips/lasat/ds1603.h b/arch/mips/lasat/ds1603.h
index 55f3b0423c2..3e718b1cca0 100644
--- a/arch/mips/lasat/ds1603.h
+++ b/arch/mips/lasat/ds1603.h
@@ -1,7 +1,7 @@
-/*
- * Dallas Semiconductors 1603 RTC driver
+/*
+ * Dallas Semiconductors 1603 RTC driver
*
- * Brian Murphy <brian@murphy.dk>
+ * Brian Murphy <brian@murphy.dk>
*
*/
#ifndef __DS1603_H
@@ -20,14 +20,12 @@ struct ds_defs {
extern struct ds_defs *ds1603;
-unsigned long ds1603_read(void);
-int ds1603_set(unsigned long);
void ds1603_set_trimmer(unsigned int);
void ds1603_enable(void);
void ds1603_disable(void);
void ds1603_init(struct ds_defs *);
-#define TRIMMER_DEFAULT 3
+#define TRIMMER_DEFAULT 3
#define TRIMMER_DISABLE_RTC 0
#endif
diff --git a/arch/mips/lasat/image/Makefile b/arch/mips/lasat/image/Makefile
index 18b6430f11b..fd32075679c 100644
--- a/arch/mips/lasat/image/Makefile
+++ b/arch/mips/lasat/image/Makefile
@@ -12,23 +12,22 @@ endif
MKLASATIMG = mklasatimg
MKLASATIMG_ARCH = mq2,mqpro,sp100,sp200
-KERNEL_IMAGE = $(TOPDIR)/vmlinux
-KERNEL_START = $(shell $(NM) $(KERNEL_IMAGE) | grep " _text" | cut -f1 -d\ )
-KERNEL_ENTRY = $(shell $(NM) $(KERNEL_IMAGE) | grep kernel_entry | cut -f1 -d\ )
+KERNEL_IMAGE = vmlinux
-LDSCRIPT= -L$(obj) -Tromscript.normal
+LDSCRIPT= -L$(srctree)/$(src) -Tromscript.normal
-HEAD_DEFINES := -D_kernel_start=0x$(KERNEL_START) \
- -D_kernel_entry=0x$(KERNEL_ENTRY) \
+HEAD_DEFINES := -D_kernel_start=$(VMLINUX_LOAD_ADDRESS) \
+ -D_kernel_entry=$(VMLINUX_ENTRY_ADDRESS) \
-D VERSION="\"$(Version)\"" \
- -D TIMESTAMP=$(shell date +%s)
+ -D TIMESTAMP=$(shell date +%s)
$(obj)/head.o: $(obj)/head.S $(KERNEL_IMAGE)
- $(CC) -fno-pic $(HEAD_DEFINES) -I$(TOPDIR)/include -c -o $@ $<
+ $(CC) -fno-pic $(HEAD_DEFINES) $(LINUXINCLUDE) -c -o $@ $<
OBJECTS = head.o kImage.o
-rom.sw: $(obj)/rom.sw
+rom.sw: $(obj)/rom.sw
+rom.bin: $(obj)/rom.bin
$(obj)/rom.sw: $(obj)/rom.bin
$(MKLASATIMG) -o $@ -k $^ -m $(MKLASATIMG_ARCH)
diff --git a/arch/mips/lasat/image/head.S b/arch/mips/lasat/image/head.S
index 426bd7de17b..41babbe43a8 100644
--- a/arch/mips/lasat/image/head.S
+++ b/arch/mips/lasat/image/head.S
@@ -1,13 +1,13 @@
#include <asm/lasat/head.h>
.text
- .section .text.start, "ax"
+ .section .text..start, "ax"
.set noreorder
.set mips3
/* Magic words identifying a software image */
.word LASAT_K_MAGIC0_VAL
- .word LASAT_K_MAGIC1_VAL
+ .word LASAT_K_MAGIC1_VAL
/* Image header version */
.word 0x00000002
@@ -27,5 +27,5 @@ reldate:
.word TIMESTAMP
.org 0x50
-release:
+release:
.string VERSION
diff --git a/arch/mips/lasat/image/romscript.normal b/arch/mips/lasat/image/romscript.normal
index ca22336f6c3..0864c963e18 100644
--- a/arch/mips/lasat/image/romscript.normal
+++ b/arch/mips/lasat/image/romscript.normal
@@ -4,7 +4,7 @@ SECTIONS
{
.text :
{
- *(.text.start)
+ *(.text..start)
}
/* Data in ROM */
@@ -16,7 +16,8 @@ SECTIONS
_image_start = ADDR(.data);
_image_size = SIZEOF(.data);
- .other : {
- *(.*)
+ .other :
+ {
+ *(.*)
}
}
diff --git a/arch/mips/lasat/interrupt.c b/arch/mips/lasat/interrupt.c
index 1148a2d20aa..d608b6ef0ed 100644
--- a/arch/mips/lasat/interrupt.c
+++ b/arch/mips/lasat/interrupt.c
@@ -15,70 +15,41 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
*
- * Routines for generic manipulation of the interrupts found on the
+ * Routines for generic manipulation of the interrupts found on the
* Lasat boards.
*/
#include <linux/init.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
#include <linux/interrupt.h>
-#include <linux/kernel_stat.h>
+#include <linux/irq.h>
-#include <asm/bootinfo.h>
-#include <asm/irq.h>
+#include <asm/irq_cpu.h>
+#include <asm/lasat/lasat.h>
#include <asm/lasat/lasatint.h>
-#include <asm/gdb-stub.h>
-static volatile int *lasat_int_status = NULL;
-static volatile int *lasat_int_mask = NULL;
-static volatile int lasat_int_mask_shift;
+#include <irq.h>
-extern asmlinkage void lasatIRQ(void);
+static volatile int *lasat_int_status;
+static volatile int *lasat_int_mask;
+static volatile int lasat_int_mask_shift;
-void disable_lasat_irq(unsigned int irq_nr)
+void disable_lasat_irq(struct irq_data *d)
{
- unsigned long flags;
+ unsigned int irq_nr = d->irq - LASAT_IRQ_BASE;
- local_irq_save(flags);
*lasat_int_mask &= ~(1 << irq_nr) << lasat_int_mask_shift;
- local_irq_restore(flags);
}
-void enable_lasat_irq(unsigned int irq_nr)
+void enable_lasat_irq(struct irq_data *d)
{
- unsigned long flags;
+ unsigned int irq_nr = d->irq - LASAT_IRQ_BASE;
- local_irq_save(flags);
*lasat_int_mask |= (1 << irq_nr) << lasat_int_mask_shift;
- local_irq_restore(flags);
-}
-
-static unsigned int startup_lasat_irq(unsigned int irq)
-{
- enable_lasat_irq(irq);
-
- return 0; /* never anything pending */
-}
-
-#define shutdown_lasat_irq disable_lasat_irq
-
-#define mask_and_ack_lasat_irq disable_lasat_irq
-
-static void end_lasat_irq(unsigned int irq)
-{
- if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
- enable_lasat_irq(irq);
}
-static struct hw_interrupt_type lasat_irq_type = {
- "Lasat",
- startup_lasat_irq,
- shutdown_lasat_irq,
- enable_lasat_irq,
- disable_lasat_irq,
- mask_and_ack_lasat_irq,
- end_lasat_irq,
- NULL
+static struct irq_chip lasat_irq_type = {
+ .name = "Lasat",
+ .irq_mask = disable_lasat_irq,
+ .irq_unmask = enable_lasat_irq,
};
static inline int ls1bit32(unsigned int x)
@@ -94,14 +65,14 @@ static inline int ls1bit32(unsigned int x)
return b;
}
-static unsigned long (* get_int_status)(void);
+static unsigned long (*get_int_status)(void);
static unsigned long get_int_status_100(void)
{
return *lasat_int_status & *lasat_int_mask;
}
-static unsigned long get_int_status_200(void)
+static unsigned long get_int_status_200(void)
{
unsigned long int_status;
@@ -110,51 +81,55 @@ static unsigned long get_int_status_200(void)
return int_status;
}
-void lasat_hw0_irqdispatch(struct pt_regs *regs)
+asmlinkage void plat_irq_dispatch(void)
{
unsigned long int_status;
+ unsigned int cause = read_c0_cause();
int irq;
+ if (cause & CAUSEF_IP7) { /* R4000 count / compare IRQ */
+ do_IRQ(7);
+ return;
+ }
+
int_status = get_int_status();
/* if int_status == 0, then the interrupt has already been cleared */
if (int_status) {
- irq = ls1bit32(int_status);
+ irq = LASAT_IRQ_BASE + ls1bit32(int_status);
- do_IRQ(irq, regs);
+ do_IRQ(irq);
}
}
+static struct irqaction cascade = {
+ .handler = no_action,
+ .name = "cascade",
+ .flags = IRQF_NO_THREAD,
+};
+
void __init arch_init_irq(void)
{
int i;
- switch (mips_machtype) {
- case MACH_LASAT_100:
- lasat_int_status = (void *)LASAT_INT_STATUS_REG_100;
- lasat_int_mask = (void *)LASAT_INT_MASK_REG_100;
- lasat_int_mask_shift = LASATINT_MASK_SHIFT_100;
- get_int_status = get_int_status_100;
- *lasat_int_mask = 0;
- break;
- case MACH_LASAT_200:
+ if (IS_LASAT_200()) {
lasat_int_status = (void *)LASAT_INT_STATUS_REG_200;
lasat_int_mask = (void *)LASAT_INT_MASK_REG_200;
lasat_int_mask_shift = LASATINT_MASK_SHIFT_200;
get_int_status = get_int_status_200;
*lasat_int_mask &= 0xffff;
- break;
- default:
- panic("arch_init_irq: mips_machtype incorrect");
+ } else {
+ lasat_int_status = (void *)LASAT_INT_STATUS_REG_100;
+ lasat_int_mask = (void *)LASAT_INT_MASK_REG_100;
+ lasat_int_mask_shift = LASATINT_MASK_SHIFT_100;
+ get_int_status = get_int_status_100;
+ *lasat_int_mask = 0;
}
- /* Now safe to set the exception vector. */
- set_except_vector(0, lasatIRQ);
+ mips_cpu_irq_init();
- for (i = 0; i <= LASATINT_END; i++) {
- irq_desc[i].status = IRQ_DISABLED;
- irq_desc[i].action = 0;
- irq_desc[i].depth = 1;
- irq_desc[i].handler = &lasat_irq_type;
- }
+ for (i = LASAT_IRQ_BASE; i <= LASAT_IRQ_END; i++)
+ irq_set_chip_and_handler(i, &lasat_irq_type, handle_level_irq);
+
+ setup_irq(LASAT_CASCADE_IRQ, &cascade);
}
diff --git a/arch/mips/lasat/lasatIRQ.S b/arch/mips/lasat/lasatIRQ.S
deleted file mode 100644
index 2a2b0d05656..00000000000
--- a/arch/mips/lasat/lasatIRQ.S
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Carsten Langgaard, carstenl@mips.com
- * Copyright (C) 1999, 2000 MIPS Technologies, Inc. All rights reserved.
- *
- * This program is free software; you can distribute it and/or modify it
- * under the terms of the GNU General Public License (Version 2) as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Interrupt exception dispatch code.
- */
-#include <asm/asm.h>
-#include <asm/mipsregs.h>
-#include <asm/regdef.h>
-#include <asm/stackframe.h>
-
- .text
- .set noreorder
- .align 5
- NESTED(lasatIRQ, PT_SIZE, sp)
- .set noat
- SAVE_ALL
- CLI
- .set at
- .set noreorder
-
- mfc0 s0, CP0_CAUSE # get irq mask
-
- /* First we check for r4k counter/timer IRQ. */
- andi a0, s0, CAUSEF_IP7
- beq a0, zero, 1f
- andi a0, s0, CAUSEF_IP2 # delay slot, check hw0 interrupt
-
- /* Wheee, a timer interrupt. */
- li a0, 7
- jal ll_timer_interrupt
- move a1, sp
-
- j ret_from_irq
- nop
-
-1:
- /* Wheee, combined hardware level zero interrupt. */
- jal lasat_hw0_irqdispatch
- move a0, sp # delay slot
-
- j ret_from_irq
- nop # delay slot
-
-1:
- /*
- * Here by mistake? This is possible, what can happen is that by the
- * time we take the exception the IRQ pin goes low, so just leave if
- * this is the case.
- */
- move a1,s0
- mfc0 a1, CP0_EPC
-
- j ret_from_irq
- nop
- END(lasatIRQ)
diff --git a/arch/mips/lasat/lasat_board.c b/arch/mips/lasat/lasat_board.c
index 8c784bcf111..577bb463a87 100644
--- a/arch/mips/lasat/lasat_board.c
+++ b/arch/mips/lasat/lasat_board.c
@@ -17,39 +17,39 @@
*
* Routines specific to the LASAT boards
*/
-#include <linux/config.h>
#include <linux/types.h>
#include <linux/crc32.h>
#include <asm/lasat/lasat.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/ctype.h>
-#include <asm/bootinfo.h>
+#include <linux/mutex.h>
#include <asm/addrspace.h>
#include "at93c.h"
/* New model description table */
#include "lasat_models.h"
-#define EEPROM_CRC(data, len) (~0 ^ crc32(~0, data, len))
+static DEFINE_MUTEX(lasat_eeprom_mutex);
-struct lasat_info lasat_board_info;
+#define EEPROM_CRC(data, len) (~crc32(~0, data, len))
-void update_bcastaddr(void);
+struct lasat_info lasat_board_info;
int EEPROMRead(unsigned int pos, unsigned char *data, int len)
{
int i;
- for (i=0; i<len; i++)
+ for (i = 0; i < len; i++)
*data++ = at93c_read(pos++);
return 0;
}
+
int EEPROMWrite(unsigned int pos, unsigned char *data, int len)
{
int i;
- for (i=0; i<len; i++)
+ for (i = 0; i < len; i++)
at93c_write(pos++, *data++);
return 0;
@@ -57,17 +57,17 @@ int EEPROMWrite(unsigned int pos, unsigned char *data, int len)
static void init_flash_sizes(void)
{
- int i;
unsigned long *lb = lasat_board_info.li_flashpart_base;
unsigned long *ls = lasat_board_info.li_flashpart_size;
+ int i;
ls[LASAT_MTD_BOOTLOADER] = 0x40000;
ls[LASAT_MTD_SERVICE] = 0xC0000;
ls[LASAT_MTD_NORMAL] = 0x100000;
- if (mips_machtype == MACH_LASAT_100) {
+ if (!IS_LASAT_200()) {
lasat_board_info.li_flash_base = 0x1e000000;
-
+
lb[LASAT_MTD_BOOTLOADER] = 0x1e400000;
if (lasat_board_info.li_flash_size > 0x200000) {
@@ -80,9 +80,9 @@ static void init_flash_sizes(void)
if (lasat_board_info.li_flash_size < 0x1000000) {
lb[LASAT_MTD_BOOTLOADER] = 0x10000000;
ls[LASAT_MTD_CONFIG] = 0x100000;
- if (lasat_board_info.li_flash_size >= 0x400000) {
- ls[LASAT_MTD_FS] = lasat_board_info.li_flash_size - 0x300000;
- }
+ if (lasat_board_info.li_flash_size >= 0x400000)
+ ls[LASAT_MTD_FS] =
+ lasat_board_info.li_flash_size - 0x300000;
}
}
@@ -95,7 +95,7 @@ int lasat_init_board_info(void)
int c;
unsigned long crc;
unsigned long cfg0, cfg1;
- const product_info_t *ppi;
+ const struct product_info *ppi;
int i_n_base_models = N_BASE_MODELS;
const char * const * i_txt_base_models = txt_base_models;
int i_n_prids = N_PRIDS;
@@ -103,7 +103,7 @@ int lasat_init_board_info(void)
memset(&lasat_board_info, 0, sizeof(lasat_board_info));
/* First read the EEPROM info */
- EEPROMRead(0, (unsigned char *)&lasat_board_info.li_eeprom_info,
+ EEPROMRead(0, (unsigned char *)&lasat_board_info.li_eeprom_info,
sizeof(struct lasat_eeprom_struct));
/* Check the CRC */
@@ -111,12 +111,13 @@ int lasat_init_board_info(void)
sizeof(struct lasat_eeprom_struct) - 4);
if (crc != lasat_board_info.li_eeprom_info.crc32) {
- prom_printf("WARNING...\nWARNING...\nEEPROM CRC does not match calculated, attempting to soldier on...\n");
+ printk(KERN_WARNING "WARNING...\nWARNING...\nEEPROM CRC does "
+ "not match calculated, attempting to soldier on...\n");
}
- if (lasat_board_info.li_eeprom_info.version != LASAT_EEPROM_VERSION)
- {
- prom_printf("WARNING...\nWARNING...\nEEPROM version %d, wanted version %d, attempting to soldier on...\n",
+ if (lasat_board_info.li_eeprom_info.version != LASAT_EEPROM_VERSION) {
+ printk(KERN_WARNING "WARNING...\nWARNING...\nEEPROM version "
+ "%d, wanted version %d, attempting to soldier on...\n",
(unsigned int)lasat_board_info.li_eeprom_info.version,
LASAT_EEPROM_VERSION);
}
@@ -124,8 +125,10 @@ int lasat_init_board_info(void)
cfg0 = lasat_board_info.li_eeprom_info.cfg[0];
cfg1 = lasat_board_info.li_eeprom_info.cfg[1];
- if ( LASAT_W0_DSCTYPE(cfg0) != 1) {
- prom_printf("WARNING...\nWARNING...\nInvalid configuration read from EEPROM, attempting to soldier on...");
+ if (LASAT_W0_DSCTYPE(cfg0) != 1) {
+ printk(KERN_WARNING "WARNING...\nWARNING...\n"
+ "Invalid configuration read from EEPROM, attempting to "
+ "soldier on...");
}
/* We have a valid configuration */
@@ -188,7 +191,7 @@ int lasat_init_board_info(void)
case 0x1:
lasat_board_info.li_cpu_hz =
lasat_board_info.li_bus_hz +
- (lasat_board_info.li_bus_hz >> 1);
+ (lasat_board_info.li_bus_hz >> 1);
break;
case 0x2:
lasat_board_info.li_cpu_hz =
@@ -238,7 +241,8 @@ int lasat_init_board_info(void)
/* Base model stuff */
if (lasat_board_info.li_bmid > i_n_base_models)
lasat_board_info.li_bmid = i_n_base_models;
- strcpy(lasat_board_info.li_bmstr, i_txt_base_models[lasat_board_info.li_bmid]);
+ strcpy(lasat_board_info.li_bmstr,
+ i_txt_base_models[lasat_board_info.li_bmid]);
/* Product ID dependent values */
c = lasat_board_info.li_prid;
@@ -251,13 +255,9 @@ int lasat_init_board_info(void)
if (ppi->pi_type)
strcpy(lasat_board_info.li_typestr, ppi->pi_type);
else
- sprintf(lasat_board_info.li_typestr, "%d",10*c);
+ sprintf(lasat_board_info.li_typestr, "%d", 10 * c);
}
-#if defined(CONFIG_INET) && defined(CONFIG_SYSCTL)
- update_bcastaddr();
-#endif
-
return 0;
}
@@ -265,13 +265,16 @@ void lasat_write_eeprom_info(void)
{
unsigned long crc;
+ mutex_lock(&lasat_eeprom_mutex);
+
/* Generate the CRC */
crc = EEPROM_CRC((unsigned char *)(&lasat_board_info.li_eeprom_info),
sizeof(struct lasat_eeprom_struct) - 4);
lasat_board_info.li_eeprom_info.crc32 = crc;
/* Write the EEPROM info */
- EEPROMWrite(0, (unsigned char *)&lasat_board_info.li_eeprom_info,
+ EEPROMWrite(0, (unsigned char *)&lasat_board_info.li_eeprom_info,
sizeof(struct lasat_eeprom_struct));
-}
+ mutex_unlock(&lasat_eeprom_mutex);
+}
diff --git a/arch/mips/lasat/lasat_models.h b/arch/mips/lasat/lasat_models.h
index ae0c5d0bd40..e1cbd26ae1b 100644
--- a/arch/mips/lasat/lasat_models.h
+++ b/arch/mips/lasat/lasat_models.h
@@ -1,24 +1,26 @@
/*
* Model description tables
*/
+#include <linux/kernel.h>
-typedef struct product_info_t {
+struct product_info {
const char *pi_name;
const char *pi_type;
-} product_info_t;
+};
-typedef struct vendor_info_t {
+struct vendor_info {
const char *vi_name;
- const product_info_t *vi_product_info;
-} vendor_info_t;
+ const struct product_info *vi_product_info;
+};
/*
* Base models
*/
static const char * const txt_base_models[] = {
- "MQ 2", "MQ Pro", "SP 25", "SP 50", "SP 100", "SP 5000", "SP 7000", "SP 1000", "Unknown"
+ "MQ 2", "MQ Pro", "SP 25", "SP 50", "SP 100", "SP 5000", "SP 7000",
+ "SP 1000", "Unknown"
};
-#define N_BASE_MODELS (sizeof(txt_base_models)/sizeof(char*)-1)
+#define N_BASE_MODELS (ARRAY_SIZE(txt_base_models) - 1)
/*
* Eicon Networks
@@ -26,38 +28,40 @@ static const char * const txt_base_models[] = {
static const char txt_en_mq[] = "Masquerade";
static const char txt_en_sp[] = "Safepipe";
-static const product_info_t product_info_eicon[] = {
- { txt_en_mq, "II" }, /* 0 */
- { txt_en_mq, "Pro" }, /* 1 */
- { txt_en_sp, "25" }, /* 2 */
- { txt_en_sp, "50" }, /* 3 */
- { txt_en_sp, "100" }, /* 4 */
- { txt_en_sp, "5000" }, /* 5 */
- { txt_en_sp, "7000" }, /* 6 */
- { txt_en_sp, "30" }, /* 7 */
- { txt_en_sp, "5100" }, /* 8 */
- { txt_en_sp, "7100" }, /* 9 */
- { txt_en_sp, "1110" }, /* 10 */
- { txt_en_sp, "3020" }, /* 11 */
- { txt_en_sp, "3030" }, /* 12 */
- { txt_en_sp, "5020" }, /* 13 */
- { txt_en_sp, "5030" }, /* 14 */
- { txt_en_sp, "1120" }, /* 15 */
- { txt_en_sp, "1130" }, /* 16 */
- { txt_en_sp, "6010" }, /* 17 */
- { txt_en_sp, "6110" }, /* 18 */
- { txt_en_sp, "6210" }, /* 19 */
- { txt_en_sp, "1020" }, /* 20 */
- { txt_en_sp, "1040" }, /* 21 */
- { txt_en_sp, "1050" }, /* 22 */
- { txt_en_sp, "1060" }, /* 23 */
+static const struct product_info product_info_eicon[] = {
+ { txt_en_mq, "II" }, /* 0 */
+ { txt_en_mq, "Pro" }, /* 1 */
+ { txt_en_sp, "25" }, /* 2 */
+ { txt_en_sp, "50" }, /* 3 */
+ { txt_en_sp, "100" }, /* 4 */
+ { txt_en_sp, "5000" }, /* 5 */
+ { txt_en_sp, "7000" }, /* 6 */
+ { txt_en_sp, "30" }, /* 7 */
+ { txt_en_sp, "5100" }, /* 8 */
+ { txt_en_sp, "7100" }, /* 9 */
+ { txt_en_sp, "1110" }, /* 10 */
+ { txt_en_sp, "3020" }, /* 11 */
+ { txt_en_sp, "3030" }, /* 12 */
+ { txt_en_sp, "5020" }, /* 13 */
+ { txt_en_sp, "5030" }, /* 14 */
+ { txt_en_sp, "1120" }, /* 15 */
+ { txt_en_sp, "1130" }, /* 16 */
+ { txt_en_sp, "6010" }, /* 17 */
+ { txt_en_sp, "6110" }, /* 18 */
+ { txt_en_sp, "6210" }, /* 19 */
+ { txt_en_sp, "1020" }, /* 20 */
+ { txt_en_sp, "1040" }, /* 21 */
+ { txt_en_sp, "1050" }, /* 22 */
+ { txt_en_sp, "1060" }, /* 23 */
};
-#define N_PRIDS (sizeof(product_info_eicon)/sizeof(product_info_t))
+
+#define N_PRIDS ARRAY_SIZE(product_info_eicon)
/*
* The vendor table
*/
-static vendor_info_t const vendor_info_table[] = {
- { "Eicon Networks", product_info_eicon },
+static struct vendor_info const vendor_info_table[] = {
+ { "Eicon Networks", product_info_eicon },
};
-#define N_VENDORS (sizeof(vendor_info_table)/sizeof(vendor_info_t))
+
+#define N_VENDORS ARRAY_SIZE(vendor_info_table)
diff --git a/arch/mips/lasat/picvue.c b/arch/mips/lasat/picvue.c
index 5637cd15392..d613b97cd51 100644
--- a/arch/mips/lasat/picvue.c
+++ b/arch/mips/lasat/picvue.c
@@ -1,7 +1,7 @@
-/*
+/*
* Picvue PVC160206 display driver
*
- * Brian Murphy <brian@murphy.dk>
+ * Brian Murphy <brian@murphy.dk>
*
*/
#include <linux/kernel.h>
@@ -9,7 +9,6 @@
#include <asm/bootinfo.h>
#include <asm/lasat/lasat.h>
#include <linux/module.h>
-#include <linux/init.h>
#include <linux/errno.h>
#include <linux/string.h>
@@ -20,16 +19,14 @@
#define PVC_DISPMEM 80
#define PVC_LINELEN PVC_DISPMEM / PVC_NLINES
-struct pvc_defs *picvue = NULL;
+struct pvc_defs *picvue;
-DECLARE_MUTEX(pvc_sem);
-
-static void pvc_reg_write(u32 val)
+static void pvc_reg_write(u32 val)
{
*picvue->reg = val;
}
-static u32 pvc_reg_read(void)
+static u32 pvc_reg_read(void)
{
u32 tmp = *picvue->reg;
return tmp;
@@ -65,12 +62,12 @@ static u8 pvc_read_data(void)
{
u32 data = pvc_reg_read();
u8 byte;
- data |= picvue->rw;
+ data |= picvue->rw;
data &= ~picvue->rs;
pvc_reg_write(data);
ndelay(40);
byte = pvc_read_byte(data);
- data |= picvue->rs;
+ data |= picvue->rs;
pvc_reg_write(data);
return byte;
}
@@ -159,47 +156,51 @@ int pvc_program_cg(int charnum, u8 bitmap[BM_SIZE])
addr = charnum * 8;
pvc_write(0x40 | addr, MODE_INST);
- for (i=0; i<BM_SIZE; i++)
+ for (i = 0; i < BM_SIZE; i++)
pvc_write(bitmap[i], MODE_DATA);
return 0;
}
#define FUNC_SET_CMD 0x20
-#define EIGHT_BYTE (1 << 4)
-#define FOUR_BYTE 0
-#define TWO_LINES (1 << 3)
-#define ONE_LINE 0
-#define LARGE_FONT (1 << 2)
-#define SMALL_FONT 0
+#define EIGHT_BYTE (1 << 4)
+#define FOUR_BYTE 0
+#define TWO_LINES (1 << 3)
+#define ONE_LINE 0
+#define LARGE_FONT (1 << 2)
+#define SMALL_FONT 0
+
static void pvc_funcset(u8 cmd)
{
- pvc_write(FUNC_SET_CMD | (cmd & (EIGHT_BYTE|TWO_LINES|LARGE_FONT)), MODE_INST);
+ pvc_write(FUNC_SET_CMD | (cmd & (EIGHT_BYTE|TWO_LINES|LARGE_FONT)),
+ MODE_INST);
}
#define ENTRYMODE_CMD 0x4
-#define AUTO_INC (1 << 1)
-#define AUTO_DEC 0
-#define CURSOR_FOLLOWS_DISP (1 << 0)
+#define AUTO_INC (1 << 1)
+#define AUTO_DEC 0
+#define CURSOR_FOLLOWS_DISP (1 << 0)
+
static void pvc_entrymode(u8 cmd)
{
- pvc_write(ENTRYMODE_CMD | (cmd & (AUTO_INC|CURSOR_FOLLOWS_DISP)), MODE_INST);
+ pvc_write(ENTRYMODE_CMD | (cmd & (AUTO_INC|CURSOR_FOLLOWS_DISP)),
+ MODE_INST);
}
#define DISP_CNT_CMD 0x08
-#define DISP_OFF 0
-#define DISP_ON (1 << 2)
-#define CUR_ON (1 << 1)
-#define CUR_BLINK (1 << 0)
+#define DISP_OFF 0
+#define DISP_ON (1 << 2)
+#define CUR_ON (1 << 1)
+#define CUR_BLINK (1 << 0)
void pvc_dispcnt(u8 cmd)
{
pvc_write(DISP_CNT_CMD | (cmd & (DISP_ON|CUR_ON|CUR_BLINK)), MODE_INST);
}
#define MOVE_CMD 0x10
-#define DISPLAY (1 << 3)
-#define CURSOR 0
-#define RIGHT (1 << 2)
-#define LEFT 0
+#define DISPLAY (1 << 3)
+#define CURSOR 0
+#define RIGHT (1 << 2)
+#define LEFT 0
void pvc_move(u8 cmd)
{
pvc_write(MOVE_CMD | (cmd & (DISPLAY|RIGHT)), MODE_INST);
diff --git a/arch/mips/lasat/picvue.h b/arch/mips/lasat/picvue.h
index 74a39039135..d0119fca386 100644
--- a/arch/mips/lasat/picvue.h
+++ b/arch/mips/lasat/picvue.h
@@ -1,11 +1,9 @@
-/*
+/*
* Picvue PVC160206 display driver
*
- * Brian Murphy <brian.murphy@eicon.com>
+ * Brian Murphy <brian.murphy@eicon.com>
*
*/
-#include <asm/semaphore.h>
-
struct pvc_defs {
volatile u32 *reg;
u32 data_shift;
@@ -31,18 +29,16 @@ void pvc_dump_string(const unsigned char *str);
int pvc_program_cg(int charnum, u8 bitmap[BM_SIZE]);
void pvc_dispcnt(u8 cmd);
-#define DISP_OFF 0
-#define DISP_ON (1 << 2)
-#define CUR_ON (1 << 1)
-#define CUR_BLINK (1 << 0)
+#define DISP_OFF 0
+#define DISP_ON (1 << 2)
+#define CUR_ON (1 << 1)
+#define CUR_BLINK (1 << 0)
void pvc_move(u8 cmd);
-#define DISPLAY (1 << 3)
-#define CURSOR 0
-#define RIGHT (1 << 2)
-#define LEFT 0
+#define DISPLAY (1 << 3)
+#define CURSOR 0
+#define RIGHT (1 << 2)
+#define LEFT 0
void pvc_clear(void);
void pvc_home(void);
-
-extern struct semaphore pvc_sem;
diff --git a/arch/mips/lasat/picvue_proc.c b/arch/mips/lasat/picvue_proc.c
index eaa2b462512..2bcd8391bc9 100644
--- a/arch/mips/lasat/picvue_proc.c
+++ b/arch/mips/lasat/picvue_proc.c
@@ -1,93 +1,117 @@
-/*
+/*
* Picvue PVC160206 display driver
*
- * Brian Murphy <brian.murphy@eicon.com>
+ * Brian Murphy <brian.murphy@eicon.com>
*
*/
+#include <linux/bug.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include <linux/interrupt.h>
#include <linux/timer.h>
+#include <linux/mutex.h>
#include "picvue.h"
+static DEFINE_MUTEX(pvc_mutex);
static char pvc_lines[PVC_NLINES][PVC_LINELEN+1];
static int pvc_linedata[PVC_NLINES];
static struct proc_dir_entry *pvc_display_dir;
static char *pvc_linename[PVC_NLINES] = {"line1", "line2"};
#define DISPLAY_DIR_NAME "display"
-static int scroll_dir = 0, scroll_interval = 0;
+static int scroll_dir, scroll_interval;
static struct timer_list timer;
-static void pvc_display(unsigned long data) {
+static void pvc_display(unsigned long data)
+{
int i;
pvc_clear();
- for (i=0; i<PVC_NLINES; i++)
+ for (i = 0; i < PVC_NLINES; i++)
pvc_write_string(pvc_lines[i], 0, i);
}
static DECLARE_TASKLET(pvc_display_tasklet, &pvc_display, 0);
-static int pvc_proc_read_line(char *page, char **start,
- off_t off, int count,
- int *eof, void *data)
+static int pvc_line_proc_show(struct seq_file *m, void *v)
{
- char *origpage = page;
- int lineno = *(int *)data;
+ int lineno = *(int *)m->private;
if (lineno < 0 || lineno > PVC_NLINES) {
- printk("proc_read_line: invalid lineno %d\n", lineno);
+ printk(KERN_WARNING "proc_read_line: invalid lineno %d\n", lineno);
return 0;
}
- down(&pvc_sem);
- page += sprintf(page, "%s\n", pvc_lines[lineno]);
- up(&pvc_sem);
+ mutex_lock(&pvc_mutex);
+ seq_printf(m, "%s\n", pvc_lines[lineno]);
+ mutex_unlock(&pvc_mutex);
- return page - origpage;
+ return 0;
}
-static int pvc_proc_write_line(struct file *file, const char *buffer,
- unsigned long count, void *data)
+static int pvc_line_proc_open(struct inode *inode, struct file *file)
{
- int origcount = count;
- int lineno = *(int *)data;
+ return single_open(file, pvc_line_proc_show, PDE_DATA(inode));
+}
- if (lineno < 0 || lineno > PVC_NLINES) {
- printk("proc_write_line: invalid lineno %d\n", lineno);
- return origcount;
- }
+static ssize_t pvc_line_proc_write(struct file *file, const char __user *buf,
+ size_t count, loff_t *pos)
+{
+ int lineno = *(int *)PDE_DATA(file_inode(file));
+ char kbuf[PVC_LINELEN];
+ size_t len;
- if (count > PVC_LINELEN)
- count = PVC_LINELEN;
+ BUG_ON(lineno < 0 || lineno > PVC_NLINES);
- if (buffer[count-1] == '\n')
- count--;
+ len = min(count, sizeof(kbuf) - 1);
+ if (copy_from_user(kbuf, buf, len))
+ return -EFAULT;
+ kbuf[len] = '\0';
- down(&pvc_sem);
- strncpy(pvc_lines[lineno], buffer, count);
- pvc_lines[lineno][count] = '\0';
- up(&pvc_sem);
+ if (len > 0 && kbuf[len - 1] == '\n')
+ len--;
+
+ mutex_lock(&pvc_mutex);
+ strncpy(pvc_lines[lineno], kbuf, len);
+ pvc_lines[lineno][len] = '\0';
+ mutex_unlock(&pvc_mutex);
tasklet_schedule(&pvc_display_tasklet);
- return origcount;
+ return count;
}
-static int pvc_proc_write_scroll(struct file *file, const char *buffer,
- unsigned long count, void *data)
+static const struct file_operations pvc_line_proc_fops = {
+ .owner = THIS_MODULE,
+ .open = pvc_line_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ .write = pvc_line_proc_write,
+};
+
+static ssize_t pvc_scroll_proc_write(struct file *file, const char __user *buf,
+ size_t count, loff_t *pos)
{
- int origcount = count;
- int cmd = simple_strtol(buffer, NULL, 10);
+ char kbuf[42];
+ size_t len;
+ int cmd;
+
+ len = min(count, sizeof(kbuf) - 1);
+ if (copy_from_user(kbuf, buf, len))
+ return -EFAULT;
+ kbuf[len] = '\0';
+
+ cmd = simple_strtol(kbuf, NULL, 10);
- down(&pvc_sem);
+ mutex_lock(&pvc_mutex);
if (scroll_interval != 0)
del_timer(&timer);
@@ -104,24 +128,33 @@ static int pvc_proc_write_scroll(struct file *file, const char *buffer,
}
add_timer(&timer);
}
- up(&pvc_sem);
+ mutex_unlock(&pvc_mutex);
- return origcount;
+ return count;
}
-static int pvc_proc_read_scroll(char *page, char **start,
- off_t off, int count,
- int *eof, void *data)
+static int pvc_scroll_proc_show(struct seq_file *m, void *v)
{
- char *origpage = page;
+ mutex_lock(&pvc_mutex);
+ seq_printf(m, "%d\n", scroll_dir * scroll_interval);
+ mutex_unlock(&pvc_mutex);
- down(&pvc_sem);
- page += sprintf(page, "%d\n", scroll_dir * scroll_interval);
- up(&pvc_sem);
+ return 0;
+}
- return page - origpage;
+static int pvc_scroll_proc_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, pvc_scroll_proc_show, NULL);
}
+static const struct file_operations pvc_scroll_proc_fops = {
+ .owner = THIS_MODULE,
+ .open = pvc_scroll_proc_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ .write = pvc_scroll_proc_write,
+};
void pvc_proc_timerfunc(unsigned long data)
{
@@ -137,12 +170,12 @@ void pvc_proc_timerfunc(unsigned long data)
static void pvc_proc_cleanup(void)
{
int i;
- for (i=0; i<PVC_NLINES; i++)
+ for (i = 0; i < PVC_NLINES; i++)
remove_proc_entry(pvc_linename[i], pvc_display_dir);
remove_proc_entry("scroll", pvc_display_dir);
remove_proc_entry(DISPLAY_DIR_NAME, NULL);
- del_timer(&timer);
+ del_timer_sync(&timer);
}
static int __init pvc_proc_init(void)
@@ -154,23 +187,20 @@ static int __init pvc_proc_init(void)
if (pvc_display_dir == NULL)
goto error;
- for (i=0; i<PVC_NLINES; i++) {
+ for (i = 0; i < PVC_NLINES; i++) {
strcpy(pvc_lines[i], "");
pvc_linedata[i] = i;
}
- for (i=0; i<PVC_NLINES; i++) {
- proc_entry = create_proc_entry(pvc_linename[i], 0644, pvc_display_dir);
+ for (i = 0; i < PVC_NLINES; i++) {
+ proc_entry = proc_create_data(pvc_linename[i], 0644, pvc_display_dir,
+ &pvc_line_proc_fops, &pvc_linedata[i]);
if (proc_entry == NULL)
goto error;
- proc_entry->read_proc = pvc_proc_read_line;
- proc_entry->write_proc = pvc_proc_write_line;
- proc_entry->data = &pvc_linedata[i];
}
- proc_entry = create_proc_entry("scroll", 0644, pvc_display_dir);
+ proc_entry = proc_create("scroll", 0644, pvc_display_dir,
+ &pvc_scroll_proc_fops);
if (proc_entry == NULL)
goto error;
- proc_entry->write_proc = pvc_proc_write_scroll;
- proc_entry->read_proc = pvc_proc_read_scroll;
init_timer(&timer);
timer.function = pvc_proc_timerfunc;
diff --git a/arch/mips/lasat/prom.c b/arch/mips/lasat/prom.c
index ca62881c9e5..20fde19a5fb 100644
--- a/arch/mips/lasat/prom.c
+++ b/arch/mips/lasat/prom.c
@@ -23,10 +23,6 @@
#define PROM_PUTC_ADDR PROM_JUMP_TABLE_ENTRY(1)
#define PROM_MONITOR_ADDR PROM_JUMP_TABLE_ENTRY(2)
-static void null_prom_printf(const char * fmt, ...)
-{
-}
-
static void null_prom_display(const char *string, int pos, int clear)
{
}
@@ -40,57 +36,47 @@ static void null_prom_putc(char c)
}
/* these are functions provided by the bootloader */
-static void (* prom_putc)(char c) = null_prom_putc;
-void (* prom_printf)(const char * fmt, ...) = null_prom_printf;
-void (* prom_display)(const char *string, int pos, int clear) =
- null_prom_display;
-void (* prom_monitor)(void) = null_prom_monitor;
+static void (*__prom_putc)(char c) = null_prom_putc;
-unsigned int lasat_ndelay_divider;
-
-#define PROM_PRINTFBUF_SIZE 256
-static char prom_printfbuf[PROM_PRINTFBUF_SIZE];
-
-static void real_prom_printf(const char * fmt, ...)
+void prom_putchar(char c)
{
- va_list ap;
- int len;
- char *c = prom_printfbuf;
- int i;
-
- va_start(ap, fmt);
- len = vsnprintf(prom_printfbuf, PROM_PRINTFBUF_SIZE, fmt, ap);
- va_end(ap);
-
- /* output overflowed the buffer */
- if (len < 0 || len > PROM_PRINTFBUF_SIZE)
- len = PROM_PRINTFBUF_SIZE;
-
- for (i=0; i < len; i++) {
- if (*c == '\n')
- prom_putc('\r');
- prom_putc(*c++);
- }
+ __prom_putc(c);
}
+void (*prom_display)(const char *string, int pos, int clear) =
+ null_prom_display;
+void (*prom_monitor)(void) = null_prom_monitor;
+
+unsigned int lasat_ndelay_divider;
+
static void setup_prom_vectors(void)
{
u32 version = *(u32 *)(RESET_VECTOR + 0x90);
if (version >= 307) {
prom_display = (void *)PROM_DISPLAY_ADDR;
- prom_putc = (void *)PROM_PUTC_ADDR;
- prom_printf = real_prom_printf;
+ __prom_putc = (void *)PROM_PUTC_ADDR;
prom_monitor = (void *)PROM_MONITOR_ADDR;
}
- prom_printf("prom vectors set up\n");
+ printk(KERN_DEBUG "prom vectors set up\n");
}
static struct at93c_defs at93c_defs[N_MACHTYPES] = {
- {(void *)AT93C_REG_100, (void *)AT93C_RDATA_REG_100, AT93C_RDATA_SHIFT_100,
- AT93C_WDATA_SHIFT_100, AT93C_CS_M_100, AT93C_CLK_M_100},
- {(void *)AT93C_REG_200, (void *)AT93C_RDATA_REG_200, AT93C_RDATA_SHIFT_200,
- AT93C_WDATA_SHIFT_200, AT93C_CS_M_200, AT93C_CLK_M_200},
+ {
+ .reg = (void *)AT93C_REG_100,
+ .rdata_reg = (void *)AT93C_RDATA_REG_100,
+ .rdata_shift = AT93C_RDATA_SHIFT_100,
+ .wdata_shift = AT93C_WDATA_SHIFT_100,
+ .cs = AT93C_CS_M_100,
+ .clk = AT93C_CLK_M_100
+ }, {
+ .reg = (void *)AT93C_REG_200,
+ .rdata_reg = (void *)AT93C_RDATA_REG_200,
+ .rdata_shift = AT93C_RDATA_SHIFT_200,
+ .wdata_shift = AT93C_WDATA_SHIFT_200,
+ .cs = AT93C_CS_M_200,
+ .clk = AT93C_CLK_M_200
+ },
};
void __init prom_init(void)
@@ -100,26 +86,22 @@ void __init prom_init(void)
setup_prom_vectors();
- if (current_cpu_data.cputype == CPU_R5000) {
- prom_printf("LASAT 200 board\n");
- mips_machtype = MACH_LASAT_200;
- lasat_ndelay_divider = LASAT_200_DIVIDER;
- } else {
- prom_printf("LASAT 100 board\n");
- mips_machtype = MACH_LASAT_100;
- lasat_ndelay_divider = LASAT_100_DIVIDER;
- }
-
- at93c = &at93c_defs[mips_machtype];
+ if (IS_LASAT_200()) {
+ printk(KERN_INFO "LASAT 200 board\n");
+ lasat_ndelay_divider = LASAT_200_DIVIDER;
+ at93c = &at93c_defs[1];
+ } else {
+ printk(KERN_INFO "LASAT 100 board\n");
+ lasat_ndelay_divider = LASAT_100_DIVIDER;
+ at93c = &at93c_defs[0];
+ }
lasat_init_board_info(); /* Read info from EEPROM */
- mips_machgroup = MACH_GROUP_LASAT;
-
/* Get the command line */
if (argc > 0) {
- strncpy(arcs_cmdline, argv[0], CL_SIZE-1);
- arcs_cmdline[CL_SIZE-1] = '\0';
+ strncpy(arcs_cmdline, argv[0], COMMAND_LINE_SIZE-1);
+ arcs_cmdline[COMMAND_LINE_SIZE-1] = '\0';
}
/* Set the I/O base address */
@@ -132,9 +114,8 @@ void __init prom_init(void)
add_memory_region(0, lasat_board_info.li_memsize, BOOT_MEM_RAM);
}
-unsigned long __init prom_free_prom_memory(void)
+void __init prom_free_prom_memory(void)
{
- return 0;
}
const char *get_system_type(void)
diff --git a/arch/mips/lasat/prom.h b/arch/mips/lasat/prom.h
index 07be7bf1e4a..337acbc2744 100644
--- a/arch/mips/lasat/prom.h
+++ b/arch/mips/lasat/prom.h
@@ -1,6 +1,7 @@
-#ifndef PROM_H
-#define PROM_H
-extern void (* prom_display)(const char *string, int pos, int clear);
-extern void (* prom_monitor)(void);
-extern void (* prom_printf)(const char * fmt, ...);
-#endif
+#ifndef __PROM_H
+#define __PROM_H
+
+extern void (*prom_display)(const char *string, int pos, int clear);
+extern void (*prom_monitor)(void);
+
+#endif /* __PROM_H */
diff --git a/arch/mips/lasat/reset.c b/arch/mips/lasat/reset.c
index 37e4912ee1c..e21f0b9a586 100644
--- a/arch/mips/lasat/reset.c
+++ b/arch/mips/lasat/reset.c
@@ -1,4 +1,4 @@
-/*
+/*
* Thomas Horsten <thh@lasat.com>
* Copyright (C) 2000 LASAT Networks A/S.
*
@@ -17,11 +17,12 @@
*
* Reset the LASAT board.
*/
-#include <linux/config.h>
#include <linux/kernel.h>
+#include <linux/pm.h>
+
#include <asm/reboot.h>
-#include <asm/system.h>
#include <asm/lasat/lasat.h>
+
#include "picvue.h"
#include "prom.h"
@@ -29,14 +30,13 @@ static void lasat_machine_restart(char *command);
static void lasat_machine_halt(void);
/* Used to set machine to boot in service mode via /proc interface */
-int lasat_boot_to_service = 0;
+int lasat_boot_to_service;
static void lasat_machine_restart(char *command)
{
local_irq_disable();
if (lasat_boot_to_service) {
- printk("machine_restart: Rebooting to service mode\n");
*(volatile unsigned int *)0xa0000024 = 0xdeadbeef;
*(volatile unsigned int *)0xa00000fc = 0xfedeabba;
}
@@ -44,17 +44,10 @@ static void lasat_machine_restart(char *command)
for (;;) ;
}
-#define MESSAGE "System halted"
static void lasat_machine_halt(void)
{
local_irq_disable();
- /* Disable interrupts and loop forever */
- printk(KERN_NOTICE MESSAGE "\n");
-#ifdef CONFIG_PICVUE
- pvc_clear();
- pvc_write_string(MESSAGE, 0, 0);
-#endif
prom_monitor();
for (;;) ;
}
@@ -63,5 +56,5 @@ void lasat_reboot_setup(void)
{
_machine_restart = lasat_machine_restart;
_machine_halt = lasat_machine_halt;
- _machine_power_off = lasat_machine_halt;
+ pm_power_off = lasat_machine_halt;
}
diff --git a/arch/mips/lasat/serial.c b/arch/mips/lasat/serial.c
new file mode 100644
index 00000000000..2e5fbed8120
--- /dev/null
+++ b/arch/mips/lasat/serial.c
@@ -0,0 +1,93 @@
+/*
+ * Registration of Lasat UART platform device.
+ *
+ * Copyright (C) 2007 Brian Murphy <brian@murphy.dk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+#include <linux/platform_device.h>
+#include <linux/serial_8250.h>
+
+#include <asm/lasat/lasat.h>
+#include <asm/lasat/serial.h>
+
+static struct resource lasat_serial_res[2] __initdata;
+
+static struct plat_serial8250_port lasat_serial8250_port[] = {
+ {
+ .iotype = UPIO_MEM,
+ .flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF |
+ UPF_SKIP_TEST,
+ },
+ {},
+};
+
+static __init int lasat_uart_add(void)
+{
+ struct platform_device *pdev;
+ int retval;
+
+ pdev = platform_device_alloc("serial8250", -1);
+ if (!pdev)
+ return -ENOMEM;
+
+ if (!IS_LASAT_200()) {
+ lasat_serial_res[0].start = KSEG1ADDR(LASAT_UART_REGS_BASE_100);
+ lasat_serial_res[0].end = lasat_serial_res[0].start + LASAT_UART_REGS_SHIFT_100 * 8 - 1;
+ lasat_serial_res[0].flags = IORESOURCE_MEM;
+ lasat_serial_res[1].start = LASATINT_UART_100;
+ lasat_serial_res[1].end = LASATINT_UART_100;
+ lasat_serial_res[1].flags = IORESOURCE_IRQ;
+
+ lasat_serial8250_port[0].mapbase = LASAT_UART_REGS_BASE_100;
+ lasat_serial8250_port[0].uartclk = LASAT_BASE_BAUD_100 * 16;
+ lasat_serial8250_port[0].regshift = LASAT_UART_REGS_SHIFT_100;
+ lasat_serial8250_port[0].irq = LASATINT_UART_100;
+ } else {
+ lasat_serial_res[0].start = KSEG1ADDR(LASAT_UART_REGS_BASE_200);
+ lasat_serial_res[0].end = lasat_serial_res[0].start + LASAT_UART_REGS_SHIFT_200 * 8 - 1;
+ lasat_serial_res[0].flags = IORESOURCE_MEM;
+ lasat_serial_res[1].start = LASATINT_UART_200;
+ lasat_serial_res[1].end = LASATINT_UART_200;
+ lasat_serial_res[1].flags = IORESOURCE_IRQ;
+
+ lasat_serial8250_port[0].mapbase = LASAT_UART_REGS_BASE_200;
+ lasat_serial8250_port[0].uartclk = LASAT_BASE_BAUD_200 * 16;
+ lasat_serial8250_port[0].regshift = LASAT_UART_REGS_SHIFT_200;
+ lasat_serial8250_port[0].irq = LASATINT_UART_200;
+ }
+
+ pdev->id = PLAT8250_DEV_PLATFORM;
+ pdev->dev.platform_data = lasat_serial8250_port;
+
+ retval = platform_device_add_resources(pdev, lasat_serial_res, ARRAY_SIZE(lasat_serial_res));
+ if (retval)
+ goto err_free_device;
+
+ retval = platform_device_add(pdev);
+ if (retval)
+ goto err_free_device;
+
+ return 0;
+
+err_free_device:
+ platform_device_put(pdev);
+
+ return retval;
+}
+device_initcall(lasat_uart_add);
diff --git a/arch/mips/lasat/setup.c b/arch/mips/lasat/setup.c
index e371ed5cbe3..dbd3163a85c 100644
--- a/arch/mips/lasat/setup.c
+++ b/arch/mips/lasat/setup.c
@@ -22,20 +22,16 @@
*
* Lasat specific setup.
*/
-#include <linux/config.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/pci.h>
#include <linux/interrupt.h>
#include <linux/tty.h>
-#include <linux/serial.h>
-#include <linux/serial_core.h>
#include <asm/time.h>
#include <asm/cpu.h>
#include <asm/bootinfo.h>
#include <asm/irq.h>
-#include <asm/serial.h>
#include <asm/lasat/lasat.h>
#include <asm/lasat/serial.h>
@@ -50,7 +46,7 @@
#include "prom.h"
-int lasat_command_line = 0;
+int lasat_command_line;
void lasatint_init(void);
extern void lasat_reboot_setup(void);
@@ -59,11 +55,16 @@ extern void edhac_init(void *, void *, void *);
extern void addrflt_init(void);
struct lasat_misc lasat_misc_info[N_MACHTYPES] = {
- {(void *)KSEG1ADDR(0x1c840000), (void *)KSEG1ADDR(0x1c800000), 2},
- {(void *)KSEG1ADDR(0x11080000), (void *)KSEG1ADDR(0x11000000), 6}
+ {
+ .reset_reg = (void *)KSEG1ADDR(0x1c840000),
+ .flash_wp_reg = (void *)KSEG1ADDR(0x1c800000), 2
+ }, {
+ .reset_reg = (void *)KSEG1ADDR(0x11080000),
+ .flash_wp_reg = (void *)KSEG1ADDR(0x11000000), 6
+ }
};
-struct lasat_misc *lasat_misc = NULL;
+struct lasat_misc *lasat_misc;
#ifdef CONFIG_DS1603
static struct ds_defs ds_defs[N_MACHTYPES] = {
@@ -105,88 +106,48 @@ static int lasat_panic_prom_monitor(struct notifier_block *this,
return NOTIFY_DONE;
}
-static struct notifier_block lasat_panic_block[] =
+static struct notifier_block lasat_panic_block[] =
{
- { lasat_panic_display, NULL, INT_MAX },
- { lasat_panic_prom_monitor, NULL, INT_MIN }
+ {
+ .notifier_call = lasat_panic_display,
+ .priority = INT_MAX
+ }, {
+ .notifier_call = lasat_panic_prom_monitor,
+ .priority = INT_MIN
+ }
};
-static void lasat_time_init(void)
+void __init plat_time_init(void)
{
mips_hpt_frequency = lasat_board_info.li_cpu_hz / 2;
-}
-
-static void lasat_timer_setup(struct irqaction *irq)
-{
- write_c0_compare(
- read_c0_count() +
- mips_hpt_frequency / HZ);
- change_c0_status(ST0_IM, IE_IRQ0 | IE_IRQ5);
+ change_c0_status(ST0_IM, IE_IRQ0);
}
-#define DYNAMIC_SERIAL_INIT
-#ifdef DYNAMIC_SERIAL_INIT
-void __init serial_init(void)
-{
-#ifdef CONFIG_SERIAL_8250
- struct uart_port s;
-
- memset(&s, 0, sizeof(s));
-
- s.flags = STD_COM_FLAGS;
- s.iotype = SERIAL_IO_MEM;
-
- if (mips_machtype == MACH_LASAT_100) {
- s.uartclk = LASAT_BASE_BAUD_100 * 16;
- s.irq = LASATINT_UART_100;
- s.regshift = LASAT_UART_REGS_SHIFT_100;
- s.membase = (char *)KSEG1ADDR(LASAT_UART_REGS_BASE_100);
- } else {
- s.uartclk = LASAT_BASE_BAUD_200 * 16;
- s.irq = LASATINT_UART_200;
- s.regshift = LASAT_UART_REGS_SHIFT_200;
- s.membase = (char *)KSEG1ADDR(LASAT_UART_REGS_BASE_200);
- }
-
- if (early_serial_setup(&s) != 0)
- printk(KERN_ERR "Serial setup failed!\n");
-#endif
-}
-#endif
-
-static int __init lasat_setup(void)
+void __init plat_mem_setup(void)
{
int i;
- lasat_misc = &lasat_misc_info[mips_machtype];
+ int lasat_type = IS_LASAT_200() ? 1 : 0;
+
+ lasat_misc = &lasat_misc_info[lasat_type];
#ifdef CONFIG_PICVUE
- picvue = &pvc_defs[mips_machtype];
+ picvue = &pvc_defs[lasat_type];
#endif
/* Set up panic notifier */
- for (i = 0; i < sizeof(lasat_panic_block) / sizeof(struct notifier_block); i++)
- notifier_chain_register(&panic_notifier_list, &lasat_panic_block[i]);
+ for (i = 0; i < ARRAY_SIZE(lasat_panic_block); i++)
+ atomic_notifier_chain_register(&panic_notifier_list,
+ &lasat_panic_block[i]);
lasat_reboot_setup();
- board_time_init = lasat_time_init;
- board_timer_setup = lasat_timer_setup;
-
#ifdef CONFIG_DS1603
- ds1603 = &ds_defs[mips_machtype];
- rtc_get_time = ds1603_read;
- rtc_set_time = ds1603_set;
+ ds1603 = &ds_defs[lasat_type];
#endif
#ifdef DYNAMIC_SERIAL_INIT
serial_init();
#endif
- /* Switch from prom exception handler to normal mode */
- change_c0_status(ST0_BEV,0);
- prom_printf("Lasat specific initialization complete\n");
-
- return 0;
+ pr_info("Lasat specific initialization complete\n");
}
-
-early_initcall(lasat_setup);
diff --git a/arch/mips/lasat/sysctl.c b/arch/mips/lasat/sysctl.c
index 1c0cc620a43..3b7f65cc421 100644
--- a/arch/mips/lasat/sysctl.c
+++ b/arch/mips/lasat/sysctl.c
@@ -20,7 +20,6 @@
#include <linux/types.h>
#include <asm/lasat/lasat.h>
-#include <linux/config.h>
#include <linux/module.h>
#include <linux/sysctl.h>
#include <linux/stddef.h>
@@ -30,161 +29,81 @@
#include <linux/string.h>
#include <linux/net.h>
#include <linux/inet.h>
-#include <asm/uaccess.h>
+#include <linux/uaccess.h>
-#include "sysctl.h"
-#include "ds1603.h"
-
-static DECLARE_MUTEX(lasat_info_sem);
+#include <asm/time.h>
-/* Strategy function to write EEPROM after changing string entry */
-int sysctl_lasatstring(ctl_table *table, int *name, int nlen,
- void *oldval, size_t *oldlenp,
- void *newval, size_t newlen, void **context)
-{
- int r;
- down(&lasat_info_sem);
- r = sysctl_string(table, name,
- nlen, oldval, oldlenp, newval, newlen, context);
- if (r < 0) {
- up(&lasat_info_sem);
- return r;
- }
- if (newval && newlen) {
- lasat_write_eeprom_info();
- }
- up(&lasat_info_sem);
- return 1;
-}
+#ifdef CONFIG_DS1603
+#include "ds1603.h"
+#endif
/* And the same for proc */
-int proc_dolasatstring(ctl_table *table, int write, struct file *filp,
+int proc_dolasatstring(struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
int r;
- down(&lasat_info_sem);
- r = proc_dostring(table, write, filp, buffer, lenp, ppos);
- if ( (!write) || r) {
- up(&lasat_info_sem);
+
+ r = proc_dostring(table, write, buffer, lenp, ppos);
+ if ((!write) || r)
return r;
- }
+
lasat_write_eeprom_info();
- up(&lasat_info_sem);
+
return 0;
}
-/* proc function to write EEPROM after changing int entry */
-int proc_dolasatint(ctl_table *table, int write, struct file *filp,
+/* proc function to write EEPROM after changing int entry */
+int proc_dolasatint(struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
int r;
- down(&lasat_info_sem);
- r = proc_dointvec(table, write, filp, buffer, lenp, ppos);
- if ( (!write) || r) {
- up(&lasat_info_sem);
+
+ r = proc_dointvec(table, write, buffer, lenp, ppos);
+ if ((!write) || r)
return r;
- }
+
lasat_write_eeprom_info();
- up(&lasat_info_sem);
+
return 0;
}
+#ifdef CONFIG_DS1603
static int rtctmp;
-#ifdef CONFIG_DS1603
-/* proc function to read/write RealTime Clock */
-int proc_dolasatrtc(ctl_table *table, int write, struct file *filp,
+/* proc function to read/write RealTime Clock */
+int proc_dolasatrtc(struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
+ struct timespec ts;
int r;
- down(&lasat_info_sem);
+
if (!write) {
- rtctmp = ds1603_read();
+ read_persistent_clock(&ts);
+ rtctmp = ts.tv_sec;
/* check for time < 0 and set to 0 */
if (rtctmp < 0)
rtctmp = 0;
}
- r = proc_dointvec(table, write, filp, buffer, lenp, ppos);
- if ( (!write) || r) {
- up(&lasat_info_sem);
+ r = proc_dointvec(table, write, buffer, lenp, ppos);
+ if (r)
return r;
- }
- ds1603_set(rtctmp);
- up(&lasat_info_sem);
- return 0;
-}
-#endif
-/* Sysctl for setting the IP addresses */
-int sysctl_lasat_intvec(ctl_table *table, int *name, int nlen,
- void *oldval, size_t *oldlenp,
- void *newval, size_t newlen, void **context)
-{
- int r;
- down(&lasat_info_sem);
- r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen, context);
- if (r < 0) {
- up(&lasat_info_sem);
- return r;
- }
- if (newval && newlen) {
- lasat_write_eeprom_info();
- }
- up(&lasat_info_sem);
- return 1;
-}
+ if (write)
+ rtc_mips_set_mmss(rtctmp);
-#ifdef CONFIG_DS1603
-/* Same for RTC */
-int sysctl_lasat_rtc(ctl_table *table, int *name, int nlen,
- void *oldval, size_t *oldlenp,
- void *newval, size_t newlen, void **context)
-{
- int r;
- down(&lasat_info_sem);
- rtctmp = ds1603_read();
- if (rtctmp < 0)
- rtctmp = 0;
- r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen, context);
- if (r < 0) {
- up(&lasat_info_sem);
- return r;
- }
- if (newval && newlen) {
- ds1603_set(rtctmp);
- }
- up(&lasat_info_sem);
- return 1;
+ return 0;
}
#endif
#ifdef CONFIG_INET
-static char lasat_bcastaddr[16];
-
-void update_bcastaddr(void)
-{
- unsigned int ip;
-
- ip = (lasat_board_info.li_eeprom_info.ipaddr &
- lasat_board_info.li_eeprom_info.netmask) |
- ~lasat_board_info.li_eeprom_info.netmask;
-
- sprintf(lasat_bcastaddr, "%d.%d.%d.%d",
- (ip ) & 0xff,
- (ip >> 8) & 0xff,
- (ip >> 16) & 0xff,
- (ip >> 24) & 0xff);
-}
-
-static char proc_lasat_ipbuf[32];
-/* Parsing of IP address */
-int proc_lasat_ip(ctl_table *table, int write, struct file *filp,
+int proc_lasat_ip(struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
- int len;
- unsigned int ip;
+ unsigned int ip;
char *p, c;
+ int len;
+ char ipbuf[32];
if (!table->data || !table->maxlen || !*lenp ||
(*ppos && !write)) {
@@ -192,153 +111,164 @@ int proc_lasat_ip(ctl_table *table, int write, struct file *filp,
return 0;
}
- down(&lasat_info_sem);
if (write) {
len = 0;
p = buffer;
while (len < *lenp) {
- if(get_user(c, p++)) {
- up(&lasat_info_sem);
+ if (get_user(c, p++))
return -EFAULT;
- }
if (c == 0 || c == '\n')
break;
len++;
}
- if (len >= sizeof(proc_lasat_ipbuf)-1)
- len = sizeof(proc_lasat_ipbuf) - 1;
- if (copy_from_user(proc_lasat_ipbuf, buffer, len))
- {
- up(&lasat_info_sem);
+ if (len >= sizeof(ipbuf)-1)
+ len = sizeof(ipbuf) - 1;
+ if (copy_from_user(ipbuf, buffer, len))
return -EFAULT;
- }
- proc_lasat_ipbuf[len] = 0;
+ ipbuf[len] = 0;
*ppos += *lenp;
/* Now see if we can convert it to a valid IP */
- ip = in_aton(proc_lasat_ipbuf);
+ ip = in_aton(ipbuf);
*(unsigned int *)(table->data) = ip;
lasat_write_eeprom_info();
} else {
ip = *(unsigned int *)(table->data);
- sprintf(proc_lasat_ipbuf, "%d.%d.%d.%d",
- (ip ) & 0xff,
- (ip >> 8) & 0xff,
+ sprintf(ipbuf, "%d.%d.%d.%d",
+ (ip) & 0xff,
+ (ip >> 8) & 0xff,
(ip >> 16) & 0xff,
(ip >> 24) & 0xff);
- len = strlen(proc_lasat_ipbuf);
+ len = strlen(ipbuf);
if (len > *lenp)
len = *lenp;
if (len)
- if(copy_to_user(buffer, proc_lasat_ipbuf, len)) {
- up(&lasat_info_sem);
+ if (copy_to_user(buffer, ipbuf, len))
return -EFAULT;
- }
if (len < *lenp) {
- if(put_user('\n', ((char *) buffer) + len)) {
- up(&lasat_info_sem);
+ if (put_user('\n', ((char *) buffer) + len))
return -EFAULT;
- }
len++;
}
*lenp = len;
*ppos += len;
}
- update_bcastaddr();
- up(&lasat_info_sem);
+
return 0;
}
-#endif /* defined(CONFIG_INET) */
+#endif
-static int sysctl_lasat_eeprom_value(ctl_table *table, int *name, int nlen,
- void *oldval, size_t *oldlenp,
- void *newval, size_t newlen,
- void **context)
+int proc_lasat_prid(struct ctl_table *table, int write,
+ void *buffer, size_t *lenp, loff_t *ppos)
{
int r;
- down(&lasat_info_sem);
- r = sysctl_intvec(table, name, nlen, oldval, oldlenp, newval, newlen, context);
- if (r < 0) {
- up(&lasat_info_sem);
+ r = proc_dointvec(table, write, buffer, lenp, ppos);
+ if (r < 0)
return r;
- }
-
- if (newval && newlen)
- {
- if (name && *name == LASAT_PRID)
- lasat_board_info.li_eeprom_info.prid = *(int*)newval;
-
+ if (write) {
+ lasat_board_info.li_eeprom_info.prid =
+ lasat_board_info.li_prid;
lasat_write_eeprom_info();
lasat_init_board_info();
}
- up(&lasat_info_sem);
-
- return 0;
-}
-
-int proc_lasat_eeprom_value(ctl_table *table, int write, struct file *filp,
- void *buffer, size_t *lenp, loff_t *ppos)
-{
- int r;
- down(&lasat_info_sem);
- r = proc_dointvec(table, write, filp, buffer, lenp, ppos);
- if ( (!write) || r) {
- up(&lasat_info_sem);
- return r;
- }
- if (filp && filp->f_dentry)
- {
- if (!strcmp(filp->f_dentry->d_name.name, "prid"))
- lasat_board_info.li_eeprom_info.prid = lasat_board_info.li_prid;
- if (!strcmp(filp->f_dentry->d_name.name, "debugaccess"))
- lasat_board_info.li_eeprom_info.debugaccess = lasat_board_info.li_debugaccess;
- }
- lasat_write_eeprom_info();
- up(&lasat_info_sem);
return 0;
}
extern int lasat_boot_to_service;
-#ifdef CONFIG_SYSCTL
-
-static ctl_table lasat_table[] = {
- {LASAT_CPU_HZ, "cpu-hz", &lasat_board_info.li_cpu_hz, sizeof(int),
- 0444, NULL, &proc_dointvec, &sysctl_intvec},
- {LASAT_BUS_HZ, "bus-hz", &lasat_board_info.li_bus_hz, sizeof(int),
- 0444, NULL, &proc_dointvec, &sysctl_intvec},
- {LASAT_MODEL, "bmid", &lasat_board_info.li_bmid, sizeof(int),
- 0444, NULL, &proc_dointvec, &sysctl_intvec},
- {LASAT_PRID, "prid", &lasat_board_info.li_prid, sizeof(int),
- 0644, NULL, &proc_lasat_eeprom_value, &sysctl_lasat_eeprom_value},
+static struct ctl_table lasat_table[] = {
+ {
+ .procname = "cpu-hz",
+ .data = &lasat_board_info.li_cpu_hz,
+ .maxlen = sizeof(int),
+ .mode = 0444,
+ .proc_handler = proc_dointvec,
+ },
+ {
+ .procname = "bus-hz",
+ .data = &lasat_board_info.li_bus_hz,
+ .maxlen = sizeof(int),
+ .mode = 0444,
+ .proc_handler = proc_dointvec,
+ },
+ {
+ .procname = "bmid",
+ .data = &lasat_board_info.li_bmid,
+ .maxlen = sizeof(int),
+ .mode = 0444,
+ .proc_handler = proc_dointvec,
+ },
+ {
+ .procname = "prid",
+ .data = &lasat_board_info.li_prid,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_lasat_prid,
+ },
#ifdef CONFIG_INET
- {LASAT_IPADDR, "ipaddr", &lasat_board_info.li_eeprom_info.ipaddr, sizeof(int),
- 0644, NULL, &proc_lasat_ip, &sysctl_lasat_intvec},
- {LASAT_NETMASK, "netmask", &lasat_board_info.li_eeprom_info.netmask, sizeof(int),
- 0644, NULL, &proc_lasat_ip, &sysctl_lasat_intvec},
- {LASAT_BCAST, "bcastaddr", &lasat_bcastaddr,
- sizeof(lasat_bcastaddr), 0600, NULL,
- &proc_dostring, &sysctl_string},
+ {
+ .procname = "ipaddr",
+ .data = &lasat_board_info.li_eeprom_info.ipaddr,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_lasat_ip,
+ },
+ {
+ .procname = "netmask",
+ .data = &lasat_board_info.li_eeprom_info.netmask,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_lasat_ip,
+ },
#endif
- {LASAT_PASSWORD, "passwd_hash", &lasat_board_info.li_eeprom_info.passwd_hash, sizeof(lasat_board_info.li_eeprom_info.passwd_hash),
- 0600, NULL, &proc_dolasatstring, &sysctl_lasatstring},
- {LASAT_SBOOT, "boot-service", &lasat_boot_to_service, sizeof(int),
- 0644, NULL, &proc_dointvec, &sysctl_intvec},
+ {
+ .procname = "passwd_hash",
+ .data = &lasat_board_info.li_eeprom_info.passwd_hash,
+ .maxlen =
+ sizeof(lasat_board_info.li_eeprom_info.passwd_hash),
+ .mode = 0600,
+ .proc_handler = proc_dolasatstring,
+ },
+ {
+ .procname = "boot-service",
+ .data = &lasat_boot_to_service,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec,
+ },
#ifdef CONFIG_DS1603
- {LASAT_RTC, "rtc", &rtctmp, sizeof(int),
- 0644, NULL, &proc_dolasatrtc, &sysctl_lasat_rtc},
+ {
+ .procname = "rtc",
+ .data = &rtctmp,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_dolasatrtc,
+ },
#endif
- {LASAT_NAMESTR, "namestr", &lasat_board_info.li_namestr, sizeof(lasat_board_info.li_namestr),
- 0444, NULL, &proc_dostring, &sysctl_string},
- {LASAT_TYPESTR, "typestr", &lasat_board_info.li_typestr, sizeof(lasat_board_info.li_typestr),
- 0444, NULL, &proc_dostring, &sysctl_string},
- {0}
+ {
+ .procname = "namestr",
+ .data = &lasat_board_info.li_namestr,
+ .maxlen = sizeof(lasat_board_info.li_namestr),
+ .mode = 0444,
+ .proc_handler = proc_dostring,
+ },
+ {
+ .procname = "typestr",
+ .data = &lasat_board_info.li_typestr,
+ .maxlen = sizeof(lasat_board_info.li_typestr),
+ .mode = 0444,
+ .proc_handler = proc_dostring,
+ },
+ {}
};
-#define CTL_LASAT 1 // CTL_ANY ???
-static ctl_table lasat_root_table[] = {
- { CTL_LASAT, "lasat", NULL, 0, 0555, lasat_table },
- { 0 }
+static struct ctl_table lasat_root_table[] = {
+ {
+ .procname = "lasat",
+ .mode = 0555,
+ .child = lasat_table
+ },
+ {}
};
static int __init lasat_register_sysctl(void)
@@ -346,10 +276,13 @@ static int __init lasat_register_sysctl(void)
struct ctl_table_header *lasat_table_header;
lasat_table_header =
- register_sysctl_table(lasat_root_table, 0);
+ register_sysctl_table(lasat_root_table);
+ if (!lasat_table_header) {
+ printk(KERN_ERR "Unable to register LASAT sysctl\n");
+ return -ENOMEM;
+ }
return 0;
}
__initcall(lasat_register_sysctl);
-#endif /* CONFIG_SYSCTL */
diff --git a/arch/mips/lasat/sysctl.h b/arch/mips/lasat/sysctl.h
deleted file mode 100644
index 4d139d2adbd..00000000000
--- a/arch/mips/lasat/sysctl.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * LASAT sysctl values
- */
-
-#ifndef _LASAT_SYSCTL_H
-#define _LASAT_SYSCTL_H
-
-/* /proc/sys/lasat */
-enum {
- LASAT_CPU_HZ=1,
- LASAT_BUS_HZ,
- LASAT_MODEL,
- LASAT_PRID,
- LASAT_IPADDR,
- LASAT_NETMASK,
- LASAT_BCAST,
- LASAT_PASSWORD,
- LASAT_SBOOT,
- LASAT_RTC,
- LASAT_NAMESTR,
- LASAT_TYPESTR,
-};
-
-#endif /* _LASAT_SYSCTL_H */