From 96532151ff3567154cac92983b9edc3138fa097c Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Wed, 11 Jul 2007 00:07:34 +0100 Subject: Revert "[MIPS] DEC: Fix modpost warning." This reverts commit 8713762acf341edea9d25d6a4817f235c67bc004. --- drivers/tc/zs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/tc/zs.c b/drivers/tc/zs.c index 4fff61b32dcb..61de78a9f6ee 100644 --- a/drivers/tc/zs.c +++ b/drivers/tc/zs.c @@ -143,7 +143,7 @@ static struct console sercons; static unsigned long break_pressed; /* break, really ... */ #endif -static unsigned char zs_init_regs[16] = { +static unsigned char zs_init_regs[16] __initdata = { 0, /* write 0 */ 0, /* write 1 */ 0, /* write 2 */ @@ -1581,7 +1581,7 @@ static void __init show_serial_version(void) /* Initialize Z8530s zs_channels */ -static void probe_sccs(void) +static void __init probe_sccs(void) { struct dec_serial **pp; int i, n, n_chips = 0, n_channels, chip, channel; @@ -1923,7 +1923,7 @@ static struct tty_driver *serial_console_device(struct console *c, int *index) * - initialize the serial port * Return non-zero if we didn't find a serial port. */ -static int serial_console_setup(struct console *co, char *options) +static int __init serial_console_setup(struct console *co, char *options) { struct dec_serial *info; int baud = 9600; -- cgit v1.2.3 From ddfada5ac00647ed0e6091322acff9d615bf7497 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Wed, 11 Jul 2007 00:20:01 +0100 Subject: [MIPS] DEC: Fix modpost warning. LD vmlinux SYSMAP System.map SYSMAP .tmp_System.map MODPOST vmlinux WARNING: drivers/built-in.o(.data+0x2480): Section mismatch: reference to .init.text: (between 'sercons' and 'ds_parms') Signed-off-by: Ralf Baechle --- drivers/tc/zs.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/tc/zs.c b/drivers/tc/zs.c index 61de78a9f6ee..ed979f13908a 100644 --- a/drivers/tc/zs.c +++ b/drivers/tc/zs.c @@ -136,7 +136,7 @@ struct dec_serial *zs_chain; /* list of all channels */ struct tty_struct zs_ttys[NUM_CHANNELS]; #ifdef CONFIG_SERIAL_DEC_CONSOLE -static struct console sercons; +static struct console zs_console; #endif #if defined(CONFIG_SERIAL_DEC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) && \ !defined(MODULE) @@ -383,7 +383,7 @@ static void receive_chars(struct dec_serial *info) #if defined(CONFIG_SERIAL_DEC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) && \ !defined(MODULE) - if (break_pressed && info->line == sercons.index) { + if (break_pressed && info->line == zs_console.index) { /* Ignore the null char got when BREAK is removed. */ if (ch == 0) continue; @@ -446,7 +446,7 @@ static void status_handle(struct dec_serial *info) if ((stat & BRK_ABRT) && !(info->read_reg_zero & BRK_ABRT)) { #if defined(CONFIG_SERIAL_DEC_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ) && \ !defined(MODULE) - if (info->line == sercons.index) { + if (info->line == zs_console.index) { if (!break_pressed) break_pressed = jiffies; } else @@ -1557,9 +1557,9 @@ static int rs_open(struct tty_struct *tty, struct file * filp) } #ifdef CONFIG_SERIAL_DEC_CONSOLE - if (sercons.cflag && sercons.index == line) { - tty->termios->c_cflag = sercons.cflag; - sercons.cflag = 0; + if (zs_console.cflag && zs_console.index == line) { + tty->termios->c_cflag = zs_console.cflag; + zs_console.cflag = 0; change_speed(info); } #endif @@ -2069,7 +2069,7 @@ static int __init serial_console_setup(struct console *co, char *options) return 0; } -static struct console sercons = { +static struct console zs_console = { .name = "ttyS", .write = serial_console_write, .device = serial_console_device, @@ -2083,7 +2083,7 @@ static struct console sercons = { */ void __init zs_serial_console_init(void) { - register_console(&sercons); + register_console(&zs_console); } #endif /* ifdef CONFIG_SERIAL_DEC_CONSOLE */ -- cgit v1.2.3 From 891649409edbed528728b4a104d29e43e9d7473a Mon Sep 17 00:00:00 2001 From: Yoichi Yuasa Date: Wed, 9 May 2007 00:03:02 +0900 Subject: [MIPS] separate platform_device registration for VR41xx serial interface Signed-off-by: Yoichi Yuasa Signed-off-by: Ralf Baechle --- arch/mips/vr41xx/common/Makefile | 2 +- arch/mips/vr41xx/common/siu.c | 120 ++++++++++++++++++++++++++++++++ drivers/serial/vr41xx_siu.c | 143 ++++++++------------------------------- include/asm-mips/vr41xx/siu.h | 2 + 4 files changed, 153 insertions(+), 114 deletions(-) create mode 100644 arch/mips/vr41xx/common/siu.c (limited to 'drivers') diff --git a/arch/mips/vr41xx/common/Makefile b/arch/mips/vr41xx/common/Makefile index f842783acd86..fcf94d7b1478 100644 --- a/arch/mips/vr41xx/common/Makefile +++ b/arch/mips/vr41xx/common/Makefile @@ -2,4 +2,4 @@ # Makefile for common code of the NEC VR4100 series. # -obj-y += bcu.o cmu.o icu.o init.o irq.o pmu.o type.o +obj-y += bcu.o cmu.o icu.o init.o irq.o pmu.o siu.o type.o diff --git a/arch/mips/vr41xx/common/siu.c b/arch/mips/vr41xx/common/siu.c new file mode 100644 index 000000000000..a1e774142163 --- /dev/null +++ b/arch/mips/vr41xx/common/siu.c @@ -0,0 +1,120 @@ +/* + * NEC VR4100 series SIU platform device. + * + * Copyright (C) 2007 Yoichi Yuasa + * + * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include +#include +#include +#include +#include + +#include +#include + +static unsigned int siu_type1_ports[SIU_PORTS_MAX] __initdata = { + PORT_VR41XX_SIU, + PORT_UNKNOWN, +}; + +static struct resource siu_type1_resource[] __initdata = { + { + .start = 0x0c000000, + .end = 0x0c00000a, + .flags = IORESOURCE_MEM, + }, + { + .start = SIU_IRQ, + .end = SIU_IRQ, + .flags = IORESOURCE_IRQ, + }, +}; + +static unsigned int siu_type2_ports[SIU_PORTS_MAX] __initdata = { + PORT_VR41XX_SIU, + PORT_VR41XX_DSIU, +}; + +static struct resource siu_type2_resource[] __initdata = { + { + .start = 0x0f000800, + .end = 0x0f00080a, + .flags = IORESOURCE_MEM, + }, + { + .start = 0x0f000820, + .end = 0x0f000829, + .flags = IORESOURCE_MEM, + }, + { + .start = SIU_IRQ, + .end = SIU_IRQ, + .flags = IORESOURCE_IRQ, + }, + { + .start = DSIU_IRQ, + .end = DSIU_IRQ, + .flags = IORESOURCE_IRQ, + }, +}; + +static int __init vr41xx_siu_add(void) +{ + struct platform_device *pdev; + struct resource *res; + unsigned int num; + int retval; + + pdev = platform_device_alloc("SIU", -1); + if (!pdev) + return -ENOMEM; + + switch (current_cpu_data.cputype) { + case CPU_VR4111: + case CPU_VR4121: + pdev->dev.platform_data = siu_type1_ports; + res = siu_type1_resource; + num = ARRAY_SIZE(siu_type1_resource); + break; + case CPU_VR4122: + case CPU_VR4131: + case CPU_VR4133: + pdev->dev.platform_data = siu_type2_ports; + res = siu_type2_resource; + num = ARRAY_SIZE(siu_type2_resource); + break; + default: + retval = -ENODEV; + goto err_free_device; + } + + retval = platform_device_add_resources(pdev, res, num); + 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(vr41xx_siu_add); diff --git a/drivers/serial/vr41xx_siu.c b/drivers/serial/vr41xx_siu.c index cf0e663b42ed..85309acb75f6 100644 --- a/drivers/serial/vr41xx_siu.c +++ b/drivers/serial/vr41xx_siu.c @@ -1,7 +1,7 @@ /* * Driver for NEC VR4100 series Serial Interface Unit. * - * Copyright (C) 2004-2005 Yoichi Yuasa + * Copyright (C) 2004-2007 Yoichi Yuasa * * Based on drivers/serial/8250.c, by Russell King. * @@ -25,12 +25,12 @@ #endif #include -#include -#include -#include +#include #include #include +#include #include +#include #include #include #include @@ -38,11 +38,9 @@ #include #include -#include #include #include -#define SIU_PORTS_MAX 2 #define SIU_BAUD_BASE 1152000 #define SIU_MAJOR 204 #define SIU_MINOR_BASE 82 @@ -60,32 +58,13 @@ #define IRUSESEL 0x02 #define SIRSEL 0x01 -struct siu_port { - unsigned int type; - unsigned int irq; - unsigned long start; -}; - -static const struct siu_port siu_type1_ports[] = { - { .type = PORT_VR41XX_SIU, - .irq = SIU_IRQ, - .start = 0x0c000000UL, }, -}; - -#define SIU_TYPE1_NR_PORTS (sizeof(siu_type1_ports) / sizeof(struct siu_port)) - -static const struct siu_port siu_type2_ports[] = { - { .type = PORT_VR41XX_SIU, - .irq = SIU_IRQ, - .start = 0x0f000800UL, }, - { .type = PORT_VR41XX_DSIU, - .irq = DSIU_IRQ, - .start = 0x0f000820UL, }, +static struct uart_port siu_uart_ports[SIU_PORTS_MAX] = { + [0 ... SIU_PORTS_MAX-1] = { + .lock = __SPIN_LOCK_UNLOCKED(siu_uart_ports->lock), + .irq = -1, + }, }; -#define SIU_TYPE2_NR_PORTS (sizeof(siu_type2_ports) / sizeof(struct siu_port)) - -static struct uart_port siu_uart_ports[SIU_PORTS_MAX]; static uint8_t lsr_break_flag[SIU_PORTS_MAX]; #define siu_read(port, offset) readb((port)->membase + (offset)) @@ -110,7 +89,6 @@ void vr41xx_select_siu_interface(siu_interface_t interface) spin_unlock_irqrestore(&port->lock, flags); } - EXPORT_SYMBOL_GPL(vr41xx_select_siu_interface); void vr41xx_use_irda(irda_use_t use) @@ -132,7 +110,6 @@ void vr41xx_use_irda(irda_use_t use) spin_unlock_irqrestore(&port->lock, flags); } - EXPORT_SYMBOL_GPL(vr41xx_use_irda); void vr41xx_select_irda_module(irda_module_t module, irda_speed_t speed) @@ -166,7 +143,6 @@ void vr41xx_select_irda_module(irda_module_t module, irda_speed_t speed) spin_unlock_irqrestore(&port->lock, flags); } - EXPORT_SYMBOL_GPL(vr41xx_select_irda_module); static inline void siu_clear_fifo(struct uart_port *port) @@ -177,21 +153,6 @@ static inline void siu_clear_fifo(struct uart_port *port) siu_write(port, UART_FCR, 0); } -static inline int siu_probe_ports(void) -{ - switch (current_cpu_data.cputype) { - case CPU_VR4111: - case CPU_VR4121: - return SIU_TYPE1_NR_PORTS; - case CPU_VR4122: - case CPU_VR4131: - case CPU_VR4133: - return SIU_TYPE2_NR_PORTS; - } - - return 0; -} - static inline unsigned long siu_port_size(struct uart_port *port) { switch (port->type) { @@ -206,21 +167,10 @@ static inline unsigned long siu_port_size(struct uart_port *port) static inline unsigned int siu_check_type(struct uart_port *port) { - switch (current_cpu_data.cputype) { - case CPU_VR4111: - case CPU_VR4121: - if (port->line == 0) - return PORT_VR41XX_SIU; - break; - case CPU_VR4122: - case CPU_VR4131: - case CPU_VR4133: - if (port->line == 0) - return PORT_VR41XX_SIU; - else if (port->line == 1) - return PORT_VR41XX_DSIU; - break; - } + if (port->line == 0) + return PORT_VR41XX_SIU; + if (port->line == 1 && port->irq != -1) + return PORT_VR41XX_DSIU; return PORT_UNKNOWN; } @@ -751,44 +701,34 @@ static struct uart_ops siu_uart_ops = { .verify_port = siu_verify_port, }; -static int siu_init_ports(void) +static int siu_init_ports(struct platform_device *pdev) { - const struct siu_port *siu; struct uart_port *port; - int i, num; + struct resource *res; + int *type = pdev->dev.platform_data; + int i; - switch (current_cpu_data.cputype) { - case CPU_VR4111: - case CPU_VR4121: - siu = siu_type1_ports; - break; - case CPU_VR4122: - case CPU_VR4131: - case CPU_VR4133: - siu = siu_type2_ports; - break; - default: + if (!type) return 0; - } port = siu_uart_ports; - num = siu_probe_ports(); - for (i = 0; i < num; i++) { - spin_lock_init(&port->lock); - port->irq = siu->irq; + for (i = 0; i < SIU_PORTS_MAX; i++) { + port->type = type[i]; + if (port->type == PORT_UNKNOWN) + continue; + port->irq = platform_get_irq(pdev, i); port->uartclk = SIU_BAUD_BASE * 16; port->fifosize = 16; port->regshift = 0; port->iotype = UPIO_MEM; port->flags = UPF_IOREMAP | UPF_BOOT_AUTOCONF; - port->type = siu->type; port->line = i; - port->mapbase = siu->start; - siu++; + res = platform_get_resource(pdev, IORESOURCE_MEM, i); + port->mapbase = res->start; port++; } - return num; + return i; } #ifdef CONFIG_SERIAL_VR41XX_CONSOLE @@ -883,13 +823,9 @@ static struct console siu_console = { static int __devinit siu_console_init(void) { struct uart_port *port; - int num, i; - - num = siu_init_ports(); - if (num <= 0) - return -ENODEV; + int i; - for (i = 0; i < num; i++) { + for (i = 0; i < SIU_PORTS_MAX; i++) { port = &siu_uart_ports[i]; port->ops = &siu_uart_ops; } @@ -920,7 +856,7 @@ static int __devinit siu_probe(struct platform_device *dev) struct uart_port *port; int num, i, retval; - num = siu_init_ports(); + num = siu_init_ports(dev); if (num <= 0) return -ENODEV; @@ -998,8 +934,6 @@ static int siu_resume(struct platform_device *dev) return 0; } -static struct platform_device *siu_platform_device; - static struct platform_driver siu_device_driver = { .probe = siu_probe, .remove = __devexit_p(siu_remove), @@ -1013,29 +947,12 @@ static struct platform_driver siu_device_driver = { static int __init vr41xx_siu_init(void) { - int retval; - - siu_platform_device = platform_device_alloc("SIU", -1); - if (!siu_platform_device) - return -ENOMEM; - - retval = platform_device_add(siu_platform_device); - if (retval < 0) { - platform_device_put(siu_platform_device); - return retval; - } - - retval = platform_driver_register(&siu_device_driver); - if (retval < 0) - platform_device_unregister(siu_platform_device); - - return retval; + return platform_driver_register(&siu_device_driver); } static void __exit vr41xx_siu_exit(void) { platform_driver_unregister(&siu_device_driver); - platform_device_unregister(siu_platform_device); } module_init(vr41xx_siu_init); diff --git a/include/asm-mips/vr41xx/siu.h b/include/asm-mips/vr41xx/siu.h index 1fcf6e8082b4..98cdb4096485 100644 --- a/include/asm-mips/vr41xx/siu.h +++ b/include/asm-mips/vr41xx/siu.h @@ -20,6 +20,8 @@ #ifndef __NEC_VR41XX_SIU_H #define __NEC_VR41XX_SIU_H +#define SIU_PORTS_MAX 2 + typedef enum { SIU_INTERFACE_RS232C, SIU_INTERFACE_IRDA, -- cgit v1.2.3 From 44173fb2e83183b585e137e6fee8ba32460f5645 Mon Sep 17 00:00:00 2001 From: Yoichi Yuasa Date: Thu, 10 May 2007 22:21:35 +0900 Subject: [MIPS] Separate platform_device registration for VR41xx GPIO Signed-off-by: Yoichi Yuasa Signed-off-by: Ralf Baechle --- arch/mips/vr41xx/common/Makefile | 2 +- arch/mips/vr41xx/common/giu.c | 122 ++++++++++++++++++++++++++++++++++++ drivers/char/vr41xx_giu.c | 132 ++++++++++----------------------------- include/asm-mips/vr41xx/giu.h | 9 +++ 4 files changed, 166 insertions(+), 99 deletions(-) create mode 100644 arch/mips/vr41xx/common/giu.c (limited to 'drivers') diff --git a/arch/mips/vr41xx/common/Makefile b/arch/mips/vr41xx/common/Makefile index fcf94d7b1478..22b074e72121 100644 --- a/arch/mips/vr41xx/common/Makefile +++ b/arch/mips/vr41xx/common/Makefile @@ -2,4 +2,4 @@ # Makefile for common code of the NEC VR4100 series. # -obj-y += bcu.o cmu.o icu.o init.o irq.o pmu.o siu.o type.o +obj-y += bcu.o cmu.o giu.o icu.o init.o irq.o pmu.o siu.o type.o diff --git a/arch/mips/vr41xx/common/giu.c b/arch/mips/vr41xx/common/giu.c new file mode 100644 index 000000000000..d21f6f2d22a3 --- /dev/null +++ b/arch/mips/vr41xx/common/giu.c @@ -0,0 +1,122 @@ +/* + * NEC VR4100 series GIU platform device. + * + * Copyright (C) 2007 Yoichi Yuasa + * + * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include +#include +#include +#include + +#include +#include +#include + +static struct resource giu_50pins_pullupdown_resource[] __initdata = { + { + .start = 0x0b000100, + .end = 0x0b00011f, + .flags = IORESOURCE_MEM, + }, + { + .start = 0x0b0002e0, + .end = 0x0b0002e3, + .flags = IORESOURCE_MEM, + }, + { + .start = GIUINT_IRQ, + .end = GIUINT_IRQ, + .flags = IORESOURCE_IRQ, + }, +}; + +static struct resource giu_36pins_resource[] __initdata = { + { + .start = 0x0f000140, + .end = 0x0f00015f, + .flags = IORESOURCE_MEM, + }, + { + .start = GIUINT_IRQ, + .end = GIUINT_IRQ, + .flags = IORESOURCE_IRQ, + }, +}; + +static struct resource giu_48pins_resource[] __initdata = { + { + .start = 0x0f000140, + .end = 0x0f000167, + .flags = IORESOURCE_MEM, + }, + { + .start = GIUINT_IRQ, + .end = GIUINT_IRQ, + .flags = IORESOURCE_IRQ, + }, +}; + +static int __init vr41xx_giu_add(void) +{ + struct platform_device *pdev; + struct resource *res; + unsigned int num; + int retval; + + pdev = platform_device_alloc("GIU", -1); + if (!pdev) + return -ENOMEM; + + switch (current_cpu_data.cputype) { + case CPU_VR4111: + case CPU_VR4121: + pdev->id = GPIO_50PINS_PULLUPDOWN; + res = giu_50pins_pullupdown_resource; + num = ARRAY_SIZE(giu_50pins_pullupdown_resource); + break; + case CPU_VR4122: + case CPU_VR4131: + pdev->id = GPIO_36PINS; + res = giu_36pins_resource; + num = ARRAY_SIZE(giu_36pins_resource); + break; + case CPU_VR4133: + pdev->id = GPIO_48PINS_EDGE_SELECT; + res = giu_48pins_resource; + num = ARRAY_SIZE(giu_48pins_resource); + break; + default: + retval = -ENODEV; + goto err_free_device; + } + + retval = platform_device_add_resources(pdev, res, num); + 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(vr41xx_giu_add); diff --git a/drivers/char/vr41xx_giu.c b/drivers/char/vr41xx_giu.c index 0cea8d4907df..e5ed09192be8 100644 --- a/drivers/char/vr41xx_giu.c +++ b/drivers/char/vr41xx_giu.c @@ -19,18 +19,17 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include #include #include #include -#include #include +#include #include #include +#include #include #include -#include #include #include #include @@ -44,18 +43,6 @@ static int major; /* default is dynamic major device number */ module_param(major, int, 0); MODULE_PARM_DESC(major, "Major device number"); -#define GIU_TYPE1_START 0x0b000100UL -#define GIU_TYPE1_SIZE 0x20UL - -#define GIU_TYPE2_START 0x0f000140UL -#define GIU_TYPE2_SIZE 0x20UL - -#define GIU_TYPE3_START 0x0f000140UL -#define GIU_TYPE3_SIZE 0x28UL - -#define GIU_PULLUPDOWN_START 0x0b0002e0UL -#define GIU_PULLUPDOWN_SIZE 0x04UL - #define GIUIOSELL 0x00 #define GIUIOSELH 0x02 #define GIUPIODL 0x04 @@ -89,8 +76,6 @@ MODULE_PARM_DESC(major, "Major device number"); #define GPIO_HAS_INTERRUPT_EDGE_SELECT 0x0100 static spinlock_t giu_lock; -static struct resource *giu_resource1; -static struct resource *giu_resource2; static unsigned long giu_flags; static unsigned int giu_nr_pins; @@ -234,7 +219,7 @@ void vr41xx_set_irq_trigger(unsigned int pin, irq_trigger_t trigger, irq_signal_ giu_set(GIUINTHTSELL, mask); else giu_clear(GIUINTHTSELL, mask); - if (current_cpu_data.cputype == CPU_VR4133) { + if (giu_flags & GPIO_HAS_INTERRUPT_EDGE_SELECT) { switch (trigger) { case IRQ_TRIGGER_EDGE_FALLING: giu_set(GIUFEDGEINHL, mask); @@ -269,7 +254,7 @@ void vr41xx_set_irq_trigger(unsigned int pin, irq_trigger_t trigger, irq_signal_ giu_set(GIUINTHTSELH, mask); else giu_clear(GIUINTHTSELH, mask); - if (current_cpu_data.cputype == CPU_VR4133) { + if (giu_flags & GPIO_HAS_INTERRUPT_EDGE_SELECT) { switch (trigger) { case IRQ_TRIGGER_EDGE_FALLING: giu_set(GIUFEDGEINHH, mask); @@ -298,7 +283,6 @@ void vr41xx_set_irq_trigger(unsigned int pin, irq_trigger_t trigger, irq_signal_ giu_write(GIUINTSTATH, mask); } } - EXPORT_SYMBOL_GPL(vr41xx_set_irq_trigger); void vr41xx_set_irq_level(unsigned int pin, irq_level_t level) @@ -321,7 +305,6 @@ void vr41xx_set_irq_level(unsigned int pin, irq_level_t level) giu_write(GIUINTSTATH, mask); } } - EXPORT_SYMBOL_GPL(vr41xx_set_irq_level); gpio_data_t vr41xx_gpio_get_pin(unsigned int pin) @@ -350,7 +333,6 @@ gpio_data_t vr41xx_gpio_get_pin(unsigned int pin) return GPIO_DATA_LOW; } - EXPORT_SYMBOL_GPL(vr41xx_gpio_get_pin); int vr41xx_gpio_set_pin(unsigned int pin, gpio_data_t data) @@ -388,7 +370,6 @@ int vr41xx_gpio_set_pin(unsigned int pin, gpio_data_t data) return 0; } - EXPORT_SYMBOL_GPL(vr41xx_gpio_set_pin); int vr41xx_gpio_set_direction(unsigned int pin, gpio_direction_t dir) @@ -438,7 +419,6 @@ int vr41xx_gpio_set_direction(unsigned int pin, gpio_direction_t dir) return 0; } - EXPORT_SYMBOL_GPL(vr41xx_gpio_set_direction); int vr41xx_gpio_pullupdown(unsigned int pin, gpio_pull_t pull) @@ -477,7 +457,6 @@ int vr41xx_gpio_pullupdown(unsigned int pin, gpio_pull_t pull) return 0; } - EXPORT_SYMBOL_GPL(vr41xx_gpio_pullupdown); static ssize_t gpio_read(struct file *file, char __user *buf, size_t len, @@ -596,61 +575,40 @@ static const struct file_operations gpio_fops = { static int __devinit giu_probe(struct platform_device *dev) { - unsigned long start, size, flags = 0; - unsigned int nr_pins = 0, trigger, i, pin; - struct resource *res1, *res2 = NULL; - void *base; + struct resource *res; + unsigned int trigger, i, pin; struct irq_chip *chip; - int retval; - - switch (current_cpu_data.cputype) { - case CPU_VR4111: - case CPU_VR4121: - start = GIU_TYPE1_START; - size = GIU_TYPE1_SIZE; - flags = GPIO_HAS_PULLUPDOWN_IO; - nr_pins = 50; + int irq, retval; + + switch (dev->id) { + case GPIO_50PINS_PULLUPDOWN: + giu_flags = GPIO_HAS_PULLUPDOWN_IO; + giu_nr_pins = 50; break; - case CPU_VR4122: - case CPU_VR4131: - start = GIU_TYPE2_START; - size = GIU_TYPE2_SIZE; - nr_pins = 36; + case GPIO_36PINS: + giu_nr_pins = 36; break; - case CPU_VR4133: - start = GIU_TYPE3_START; - size = GIU_TYPE3_SIZE; - flags = GPIO_HAS_INTERRUPT_EDGE_SELECT; - nr_pins = 48; + case GPIO_48PINS_EDGE_SELECT: + giu_flags = GPIO_HAS_INTERRUPT_EDGE_SELECT; + giu_nr_pins = 48; break; default: + printk(KERN_ERR "GIU: unknown ID %d\n", dev->id); return -ENODEV; } - res1 = request_mem_region(start, size, "GIU"); - if (res1 == NULL) + res = platform_get_resource(dev, IORESOURCE_MEM, 0); + if (!res) return -EBUSY; - base = ioremap(start, size); - if (base == NULL) { - release_resource(res1); + giu_base = ioremap(res->start, res->end - res->start + 1); + if (!giu_base) return -ENOMEM; - } - - if (flags & GPIO_HAS_PULLUPDOWN_IO) { - res2 = request_mem_region(GIU_PULLUPDOWN_START, GIU_PULLUPDOWN_SIZE, "GIU"); - if (res2 == NULL) { - iounmap(base); - release_resource(res1); - return -EBUSY; - } - } retval = register_chrdev(major, "GIU", &gpio_fops); if (retval < 0) { - iounmap(base); - release_resource(res1); - release_resource(res2); + iounmap(giu_base); + giu_base = NULL; return retval; } @@ -660,11 +618,6 @@ static int __devinit giu_probe(struct platform_device *dev) } spin_lock_init(&giu_lock); - giu_base = base; - giu_resource1 = res1; - giu_resource2 = res2; - giu_flags = flags; - giu_nr_pins = nr_pins; giu_write(GIUINTENL, 0); giu_write(GIUINTENH, 0); @@ -685,22 +638,23 @@ static int __devinit giu_probe(struct platform_device *dev) } - return cascade_irq(GIUINT_IRQ, giu_get_irq); + irq = platform_get_irq(dev, 0); + if (irq < 0 || irq >= NR_IRQS) + return -EBUSY; + + return cascade_irq(irq, giu_get_irq); } static int __devexit giu_remove(struct platform_device *dev) { - iounmap(giu_base); - - release_resource(giu_resource1); - if (giu_flags & GPIO_HAS_PULLUPDOWN_IO) - release_resource(giu_resource2); + if (giu_base) { + iounmap(giu_base); + giu_base = NULL; + } return 0; } -static struct platform_device *giu_platform_device; - static struct platform_driver giu_device_driver = { .probe = giu_probe, .remove = __devexit_p(giu_remove), @@ -712,30 +666,12 @@ static struct platform_driver giu_device_driver = { static int __init vr41xx_giu_init(void) { - int retval; - - giu_platform_device = platform_device_alloc("GIU", -1); - if (!giu_platform_device) - return -ENOMEM; - - retval = platform_device_add(giu_platform_device); - if (retval < 0) { - platform_device_put(giu_platform_device); - return retval; - } - - retval = platform_driver_register(&giu_device_driver); - if (retval < 0) - platform_device_unregister(giu_platform_device); - - return retval; + return platform_driver_register(&giu_device_driver); } static void __exit vr41xx_giu_exit(void) { platform_driver_unregister(&giu_device_driver); - - platform_device_unregister(giu_platform_device); } module_init(vr41xx_giu_init); diff --git a/include/asm-mips/vr41xx/giu.h b/include/asm-mips/vr41xx/giu.h index 8109cda557dc..0bcdd3a5c256 100644 --- a/include/asm-mips/vr41xx/giu.h +++ b/include/asm-mips/vr41xx/giu.h @@ -20,6 +20,15 @@ #ifndef __NEC_VR41XX_GIU_H #define __NEC_VR41XX_GIU_H +/* + * NEC VR4100 series GIU platform device IDs. + */ +enum { + GPIO_50PINS_PULLUPDOWN, + GPIO_36PINS, + GPIO_48PINS_EDGE_SELECT, +}; + typedef enum { IRQ_TRIGGER_LEVEL, IRQ_TRIGGER_EDGE, -- cgit v1.2.3 From bd0765098bf22eb8b1319f649a4c3301b40ec04c Mon Sep 17 00:00:00 2001 From: Yoichi Yuasa Date: Fri, 11 May 2007 21:18:48 +0900 Subject: [MIPS] separate platform_device registration for VR41xx RTC Signed-off-by: Yoichi Yuasa Signed-off-by: Ralf Baechle --- arch/mips/vr41xx/common/Makefile | 2 +- arch/mips/vr41xx/common/rtc.c | 117 ++++++++++++++++++++++++ drivers/rtc/rtc-vr41xx.c | 186 +++++++++++++++------------------------ 3 files changed, 190 insertions(+), 115 deletions(-) create mode 100644 arch/mips/vr41xx/common/rtc.c (limited to 'drivers') diff --git a/arch/mips/vr41xx/common/Makefile b/arch/mips/vr41xx/common/Makefile index 22b074e72121..d0d84ec8d63d 100644 --- a/arch/mips/vr41xx/common/Makefile +++ b/arch/mips/vr41xx/common/Makefile @@ -2,4 +2,4 @@ # Makefile for common code of the NEC VR4100 series. # -obj-y += bcu.o cmu.o giu.o icu.o init.o irq.o pmu.o siu.o type.o +obj-y += bcu.o cmu.o giu.o icu.o init.o irq.o pmu.o rtc.o siu.o type.o diff --git a/arch/mips/vr41xx/common/rtc.c b/arch/mips/vr41xx/common/rtc.c new file mode 100644 index 000000000000..cce605b3d688 --- /dev/null +++ b/arch/mips/vr41xx/common/rtc.c @@ -0,0 +1,117 @@ +/* + * NEC VR4100 series RTC platform device. + * + * Copyright (C) 2007 Yoichi Yuasa + * + * 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 Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include +#include +#include +#include + +#include +#include + +static struct resource rtc_type1_resource[] __initdata = { + { + .start = 0x0b0000c0, + .end = 0x0b0000df, + .flags = IORESOURCE_MEM, + }, + { + .start = 0x0b0001c0, + .end = 0x0b0001df, + .flags = IORESOURCE_MEM, + }, + { + .start = ELAPSEDTIME_IRQ, + .end = ELAPSEDTIME_IRQ, + .flags = IORESOURCE_IRQ, + }, + { + .start = RTCLONG1_IRQ, + .end = RTCLONG1_IRQ, + .flags = IORESOURCE_IRQ, + }, +}; + +static struct resource rtc_type2_resource[] __initdata = { + { + .start = 0x0f000100, + .end = 0x0f00011f, + .flags = IORESOURCE_MEM, + }, + { + .start = 0x0f000120, + .end = 0x0f00013f, + .flags = IORESOURCE_MEM, + }, + { + .start = ELAPSEDTIME_IRQ, + .end = ELAPSEDTIME_IRQ, + .flags = IORESOURCE_IRQ, + }, + { + .start = RTCLONG1_IRQ, + .end = RTCLONG1_IRQ, + .flags = IORESOURCE_IRQ, + }, +}; + +static int __init vr41xx_rtc_add(void) +{ + struct platform_device *pdev; + struct resource *res; + unsigned int num; + int retval; + + pdev = platform_device_alloc("RTC", -1); + if (!pdev) + return -ENOMEM; + + switch (current_cpu_data.cputype) { + case CPU_VR4111: + case CPU_VR4121: + res = rtc_type1_resource; + num = ARRAY_SIZE(rtc_type1_resource); + break; + case CPU_VR4122: + case CPU_VR4131: + case CPU_VR4133: + res = rtc_type2_resource; + num = ARRAY_SIZE(rtc_type2_resource); + break; + default: + retval = -ENODEV; + goto err_free_device; + } + + retval = platform_device_add_resources(pdev, res, num); + 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(vr41xx_rtc_add); diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c index af7596ef29e2..ce2f78de7a80 100644 --- a/drivers/rtc/rtc-vr41xx.c +++ b/drivers/rtc/rtc-vr41xx.c @@ -17,10 +17,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include #include #include #include -#include +#include #include #include #include @@ -30,25 +31,11 @@ #include #include #include -#include MODULE_AUTHOR("Yoichi Yuasa "); MODULE_DESCRIPTION("NEC VR4100 series RTC driver"); MODULE_LICENSE("GPL"); -#define RTC1_TYPE1_START 0x0b0000c0UL -#define RTC1_TYPE1_END 0x0b0000dfUL -#define RTC2_TYPE1_START 0x0b0001c0UL -#define RTC2_TYPE1_END 0x0b0001dfUL - -#define RTC1_TYPE2_START 0x0f000100UL -#define RTC1_TYPE2_END 0x0f00011fUL -#define RTC2_TYPE2_START 0x0f000120UL -#define RTC2_TYPE2_END 0x0f00013fUL - -#define RTC1_SIZE 0x20 -#define RTC2_SIZE 0x20 - /* RTC 1 registers */ #define ETIMELREG 0x00 #define ETIMEMREG 0x02 @@ -98,13 +85,8 @@ static char rtc_name[] = "RTC"; static unsigned long periodic_frequency; static unsigned long periodic_count; static unsigned int alarm_enabled; - -struct resource rtc_resource[2] = { - { .name = rtc_name, - .flags = IORESOURCE_MEM, }, - { .name = rtc_name, - .flags = IORESOURCE_MEM, }, -}; +static int aie_irq = -1; +static int pie_irq = -1; static inline unsigned long read_elapsed_second(void) { @@ -150,8 +132,8 @@ static void vr41xx_rtc_release(struct device *dev) spin_unlock_irq(&rtc_lock); - disable_irq(ELAPSEDTIME_IRQ); - disable_irq(RTCLONG1_IRQ); + disable_irq(aie_irq); + disable_irq(pie_irq); } static int vr41xx_rtc_read_time(struct device *dev, struct rtc_time *time) @@ -209,14 +191,14 @@ static int vr41xx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) spin_lock_irq(&rtc_lock); if (alarm_enabled) - disable_irq(ELAPSEDTIME_IRQ); + disable_irq(aie_irq); rtc1_write(ECMPLREG, (uint16_t)(alarm_sec << 15)); rtc1_write(ECMPMREG, (uint16_t)(alarm_sec >> 1)); rtc1_write(ECMPHREG, (uint16_t)(alarm_sec >> 17)); if (wkalrm->enabled) - enable_irq(ELAPSEDTIME_IRQ); + enable_irq(aie_irq); alarm_enabled = wkalrm->enabled; @@ -234,7 +216,7 @@ static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long spin_lock_irq(&rtc_lock); if (!alarm_enabled) { - enable_irq(ELAPSEDTIME_IRQ); + enable_irq(aie_irq); alarm_enabled = 1; } @@ -244,17 +226,17 @@ static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long spin_lock_irq(&rtc_lock); if (alarm_enabled) { - disable_irq(ELAPSEDTIME_IRQ); + disable_irq(aie_irq); alarm_enabled = 0; } spin_unlock_irq(&rtc_lock); break; case RTC_PIE_ON: - enable_irq(RTCLONG1_IRQ); + enable_irq(pie_irq); break; case RTC_PIE_OFF: - disable_irq(RTCLONG1_IRQ); + disable_irq(pie_irq); break; case RTC_IRQP_READ: return put_user(periodic_frequency, (unsigned long __user *)arg); @@ -331,31 +313,37 @@ static const struct rtc_class_ops vr41xx_rtc_ops = { static int __devinit rtc_probe(struct platform_device *pdev) { + struct resource *res; struct rtc_device *rtc; - unsigned int irq; int retval; - if (pdev->num_resources != 2) + if (pdev->num_resources != 4) return -EBUSY; - rtc1_base = ioremap(pdev->resource[0].start, RTC1_SIZE); - if (rtc1_base == NULL) + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) return -EBUSY; - rtc2_base = ioremap(pdev->resource[1].start, RTC2_SIZE); - if (rtc2_base == NULL) { - iounmap(rtc1_base); - rtc1_base = NULL; + rtc1_base = ioremap(res->start, res->end - res->start + 1); + if (!rtc1_base) return -EBUSY; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); + if (!res) { + retval = -EBUSY; + goto err_rtc1_iounmap; + } + + rtc2_base = ioremap(res->start, res->end - res->start + 1); + if (!rtc2_base) { + retval = -EBUSY; + goto err_rtc1_iounmap; } rtc = rtc_device_register(rtc_name, &pdev->dev, &vr41xx_rtc_ops, THIS_MODULE); if (IS_ERR(rtc)) { - iounmap(rtc1_base); - iounmap(rtc2_base); - rtc1_base = NULL; - rtc2_base = NULL; - return PTR_ERR(rtc); + retval = PTR_ERR(rtc); + goto err_iounmap_all; } spin_lock_irq(&rtc_lock); @@ -368,35 +356,50 @@ static int __devinit rtc_probe(struct platform_device *pdev) spin_unlock_irq(&rtc_lock); - irq = ELAPSEDTIME_IRQ; - retval = request_irq(irq, elapsedtime_interrupt, IRQF_DISABLED, - "elapsed_time", pdev); - if (retval == 0) { - irq = RTCLONG1_IRQ; - retval = request_irq(irq, rtclong1_interrupt, IRQF_DISABLED, - "rtclong1", pdev); + aie_irq = platform_get_irq(pdev, 0); + if (aie_irq < 0 || aie_irq >= NR_IRQS) { + retval = -EBUSY; + goto err_device_unregister; } - if (retval < 0) { - printk(KERN_ERR "rtc: IRQ%d is busy\n", irq); - rtc_device_unregister(rtc); - if (irq == RTCLONG1_IRQ) - free_irq(ELAPSEDTIME_IRQ, NULL); - iounmap(rtc1_base); - iounmap(rtc2_base); - rtc1_base = NULL; - rtc2_base = NULL; - return retval; - } + retval = request_irq(aie_irq, elapsedtime_interrupt, IRQF_DISABLED, + "elapsed_time", pdev); + if (retval < 0) + goto err_device_unregister; + + pie_irq = platform_get_irq(pdev, 1); + if (pie_irq < 0 || pie_irq >= NR_IRQS) + goto err_free_irq; + + retval = request_irq(pie_irq, rtclong1_interrupt, IRQF_DISABLED, + "rtclong1", pdev); + if (retval < 0) + goto err_free_irq; platform_set_drvdata(pdev, rtc); - disable_irq(ELAPSEDTIME_IRQ); - disable_irq(RTCLONG1_IRQ); + disable_irq(aie_irq); + disable_irq(pie_irq); printk(KERN_INFO "rtc: Real Time Clock of NEC VR4100 series\n"); return 0; + +err_free_irq: + free_irq(aie_irq, pdev); + +err_device_unregister: + rtc_device_unregister(rtc); + +err_iounmap_all: + iounmap(rtc2_base); + rtc2_base = NULL; + +err_rtc1_iounmap: + iounmap(rtc1_base); + rtc1_base = NULL; + + return retval; } static int __devexit rtc_remove(struct platform_device *pdev) @@ -404,23 +407,21 @@ static int __devexit rtc_remove(struct platform_device *pdev) struct rtc_device *rtc; rtc = platform_get_drvdata(pdev); - if (rtc != NULL) + if (rtc) rtc_device_unregister(rtc); platform_set_drvdata(pdev, NULL); - free_irq(ELAPSEDTIME_IRQ, NULL); - free_irq(RTCLONG1_IRQ, NULL); - if (rtc1_base != NULL) + free_irq(aie_irq, pdev); + free_irq(pie_irq, pdev); + if (rtc1_base) iounmap(rtc1_base); - if (rtc2_base != NULL) + if (rtc2_base) iounmap(rtc2_base); return 0; } -static struct platform_device *rtc_platform_device; - static struct platform_driver rtc_platform_driver = { .probe = rtc_probe, .remove = __devexit_p(rtc_remove), @@ -432,55 +433,12 @@ static struct platform_driver rtc_platform_driver = { static int __init vr41xx_rtc_init(void) { - int retval; - - switch (current_cpu_data.cputype) { - case CPU_VR4111: - case CPU_VR4121: - rtc_resource[0].start = RTC1_TYPE1_START; - rtc_resource[0].end = RTC1_TYPE1_END; - rtc_resource[1].start = RTC2_TYPE1_START; - rtc_resource[1].end = RTC2_TYPE1_END; - break; - case CPU_VR4122: - case CPU_VR4131: - case CPU_VR4133: - rtc_resource[0].start = RTC1_TYPE2_START; - rtc_resource[0].end = RTC1_TYPE2_END; - rtc_resource[1].start = RTC2_TYPE2_START; - rtc_resource[1].end = RTC2_TYPE2_END; - break; - default: - return -ENODEV; - break; - } - - rtc_platform_device = platform_device_alloc("RTC", -1); - if (rtc_platform_device == NULL) - return -ENOMEM; - - retval = platform_device_add_resources(rtc_platform_device, - rtc_resource, ARRAY_SIZE(rtc_resource)); - - if (retval == 0) - retval = platform_device_add(rtc_platform_device); - - if (retval < 0) { - platform_device_put(rtc_platform_device); - return retval; - } - - retval = platform_driver_register(&rtc_platform_driver); - if (retval < 0) - platform_device_unregister(rtc_platform_device); - - return retval; + return platform_driver_register(&rtc_platform_driver); } static void __exit vr41xx_rtc_exit(void) { platform_driver_unregister(&rtc_platform_driver); - platform_device_unregister(rtc_platform_device); } module_init(vr41xx_rtc_init); -- cgit v1.2.3 From fdc1f93847ea618e51f001805e022794d8bffff3 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Thu, 12 Jul 2007 17:41:21 +0100 Subject: [MIPS] Don't use genrtc. The only pseudo-legitimate MIPS user of genrtc was a systems that doesn't have an RTC in hardware at all. At this point faking one is a little pointless ... --- arch/mips/configs/yosemite_defconfig | 2 - drivers/char/Kconfig | 2 +- include/asm-mips/rtc.h | 73 ------------------------------------ 3 files changed, 1 insertion(+), 76 deletions(-) delete mode 100644 include/asm-mips/rtc.h (limited to 'drivers') diff --git a/arch/mips/configs/yosemite_defconfig b/arch/mips/configs/yosemite_defconfig index f1cdb12f7925..f342d8c887b8 100644 --- a/arch/mips/configs/yosemite_defconfig +++ b/arch/mips/configs/yosemite_defconfig @@ -592,8 +592,6 @@ CONFIG_LEGACY_PTY_COUNT=256 # CONFIG_WATCHDOG is not set # CONFIG_HW_RANDOM is not set # CONFIG_RTC is not set -CONFIG_GEN_RTC=y -CONFIG_GEN_RTC_X=y # CONFIG_DTLK is not set # CONFIG_R3964 is not set # CONFIG_APPLICOM is not set diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index ef683ebd367c..a31c6d2c061f 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -815,7 +815,7 @@ config SGI_IP27_RTC config GEN_RTC tristate "Generic /dev/rtc emulation" - depends on RTC!=y && !IA64 && !ARM && !M32R && !SPARC && !FRV && !S390 && !SUPERH + depends on RTC!=y && !IA64 && !ARM && !M32R && !MIPS && !SPARC && !FRV && !S390 && !SUPERH ---help--- If you say Y here and create a character special file /dev/rtc with major number 10 and minor number 135 using mknod ("man mknod"), you diff --git a/include/asm-mips/rtc.h b/include/asm-mips/rtc.h deleted file mode 100644 index 82ad401c7dca..000000000000 --- a/include/asm-mips/rtc.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * include/asm-mips/rtc.h - * - * (Really an interface for drivers/char/genrtc.c) - * - * Copyright (C) 2004 MontaVista Software Inc. - * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net - * - * Please read the COPYING file for all license details. - */ - -#ifndef _MIPS_RTC_H -#define _MIPS_RTC_H - -#ifdef __KERNEL__ - -#include -#include - -#define RTC_PIE 0x40 /* periodic interrupt enable */ -#define RTC_AIE 0x20 /* alarm interrupt enable */ -#define RTC_UIE 0x10 /* update-finished interrupt enable */ - -/* some dummy definitions */ -#define RTC_BATT_BAD 0x100 /* battery bad */ -#define RTC_SQWE 0x08 /* enable square-wave output */ -#define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */ -#define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */ -#define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */ - -static inline unsigned int get_rtc_time(struct rtc_time *time) -{ - unsigned long nowtime; - - nowtime = rtc_mips_get_time(); - to_tm(nowtime, time); - time->tm_year -= 1900; - - return RTC_24H; -} - -static inline int set_rtc_time(struct rtc_time *time) -{ - unsigned long nowtime; - int ret; - - nowtime = mktime(time->tm_year+1900, time->tm_mon+1, - time->tm_mday, time->tm_hour, time->tm_min, - time->tm_sec); - ret = rtc_mips_set_time(nowtime); - - return ret; -} - -static inline unsigned int get_rtc_ss(void) -{ - struct rtc_time h; - - get_rtc_time(&h); - return h.tm_sec; -} - -static inline int get_rtc_pll(struct rtc_pll_info *pll) -{ - return -EINVAL; -} - -static inline int set_rtc_pll(struct rtc_pll_info *pll) -{ - return -EINVAL; -} -#endif -#endif -- cgit v1.2.3