[LV] Current state of RTC rework.
Hi! This is currently in my RTC rework branch. I've still not decided how to do the Kconfig'ury for it... arch/vax/kernel/clock.c | 70 ------------------------------------- b/arch/vax/Kconfig | 8 ++++ b/arch/vax/kernel/Makefile | 4 +- b/arch/vax/kernel/cpu_ka41.c | 4 +- b/arch/vax/kernel/cpu_ka410.c | 18 +++++++++ b/arch/vax/kernel/cpu_ka42.c | 4 +- b/arch/vax/kernel/cpu_ka43.c | 4 +- b/arch/vax/kernel/cpu_ka46.c | 4 +- b/arch/vax/kernel/cpu_ka48.c | 4 +- b/arch/vax/kernel/cpu_ka49.c | 4 +- b/arch/vax/kernel/cpu_ka52.c | 4 +- b/arch/vax/kernel/cpu_ka55.c | 2 - b/arch/vax/kernel/cpu_ka62.c | 16 ++++++++ b/arch/vax/kernel/cpu_ka630.c | 16 ++++++++ b/arch/vax/kernel/cpu_ka640.c | 16 ++++++++ b/arch/vax/kernel/cpu_ka650.c | 3 + b/arch/vax/kernel/cpu_ka660.c | 3 + b/arch/vax/kernel/cpu_vxt.c | 3 + b/arch/vax/kernel/rtc-generic.c | 75 ++++++++++++++++++++++++++++++++++++++++ b/include/asm-vax/clock.h | 22 ++++++----- b/include/asm-vax/mv.h | 3 - 21 files changed, 193 insertions(+), 94 deletions(-) diff --git a/arch/vax/Kconfig b/arch/vax/Kconfig index d62323f..45cf6a6 100644 --- a/arch/vax/Kconfig +++ b/arch/vax/Kconfig @@ -70,6 +70,14 @@ config CMDLINE help This is the command line the booting kernel will get. +config VAX_RTC + bool "VAX RTC support" + default y + help + This enables RTC support. You'll probably want to have this. + +source "drivers/rtc/Kconfig" + config EARLY_PRINTK bool default y diff --git a/arch/vax/kernel/Makefile b/arch/vax/kernel/Makefile index d5cb600..6bdd541 100644 --- a/arch/vax/kernel/Makefile +++ b/arch/vax/kernel/Makefile @@ -9,7 +9,7 @@ extra-y := vmlinux.lds obj-y := ptrace.o process.o setup.o regdump.o interrupt.o entry.o time.o \ ioprobe.o syscall.o signal.o semaphore.o vax_dev_init.o \ - init_task.o reboot.o cpu_generic.o clock.o + init_task.o reboot.o cpu_generic.o obj-y += bootcons/ @@ -29,7 +29,7 @@ obj-$(CONFIG_CPU_KA660) += cpu_ka660.o obj-$(CONFIG_CPU_VXT) += cpu_vxt.o obj-$(CONFIG_MODULES) += module.o +obj-$(CONFIG_VAX_RTC) += rtc-generic.o obj-$(CONFIG_VAX_DIAG_LED) += diag_led.o - obj-$(CONFIG_EARLY_PRINTK) += early_printk.o diff --git a/arch/vax/kernel/clock.c b/arch/vax/kernel/clock.c deleted file mode 100644 index 1045629..0000000 --- a/arch/vax/kernel/clock.c +++ /dev/null @@ -1,70 +0,0 @@ -/* arch/vax/kernel/clock.c - * - * Copyright atp 2002. license: GPL - * - * Routines to manipulate the real time clock on VAXen. - * - * There are two sorts of battery backed hardware clocks. There is the - * TODR (time of day register) found on big VAXen, and the familiar - * Dallas CMOS clock on the desktop VAXen. - * - * The init routines are called through the machine vector. See - * cpu_kaxx.c for details of that. The callers are time_init() and - * the rtc clock driver (drivers/char/rtc.c), using macros defined - * in asm/mc146818rtc.h. - * - * Prototypes for some of these functions are in asm/mc146818rtc.h - * and some in asm/clock.h. (The ones that are used in the mv - * initialisation are in clock.h, and the ones used in mc146818rtc.h - * are in that file). - * - */ - -#include <linux/config.h> -#include <asm/io.h> /* For ioremap() */ -#include <asm/mtpr.h> -#include <asm/mv.h> -#include <asm/clock.h> /* for TODR, if anyone feels like implementing it */ -#include <asm/bus/vsbus.h> -#include <linux/mc146818rtc.h> /* includes asm/mc146818rtc.h */ - /* - needed for offsets in debug output */ - - -/* this does nothing, and is a placeholder */ -void generic_clock_init(void) -{ - printk (KERN_WARNING "No RTC used\n"); - return; -} - -/* Map the ROM clock page, and put address in mv */ -void ka4x_clock_init(void) -{ - mv->clock_base = ioremap(VSA_CLOCK_BASE, 1); /* FIXME: 1 is the wrong len! */ - printk("Mapped RTC clock page (v %p p %08x )\n", mv->clock_base, - VSA_CLOCK_BASE); - - printk("RTC date is %2.2d:%2.2d:%4.4d %2.2d:%2.2d:%2.2d\n", - CMOS_READ(RTC_DAY_OF_MONTH), CMOS_READ(RTC_MONTH), - CMOS_READ(RTC_YEAR), CMOS_READ(RTC_HOURS), - CMOS_READ(RTC_MINUTES), CMOS_READ(RTC_SECONDS)); - - return; -} - -unsigned char ka4x_clock_read(unsigned long offset) -{ - if (mv->clock_base) - return mv->clock_base[offset] >> 2; - - return 0; -} - -void ka4x_clock_write(unsigned char val, unsigned long offset) -{ - if (mv->clock_base) - mv->clock_base[offset] = val << 2; - - return; -} - diff --git a/arch/vax/kernel/cpu_ka41.c b/arch/vax/kernel/cpu_ka41.c index 7699553..2a561e8 100644 --- a/arch/vax/kernel/cpu_ka41.c +++ b/arch/vax/kernel/cpu_ka41.c @@ -36,7 +36,6 @@ struct vax_mv mv_ka41 = { .post_vm_putchar = dz11_putchar, .post_vm_getchar = dz11_getchar, .cpu_type_str = ka41_cpu_type_str, - .clock_init = ka4x_clock_init, }; static struct cpu_match __CPU_MATCH cpu_match_ka41 = { @@ -65,6 +64,9 @@ static int __init ka41_platform_device_i return -ENODEV; platform_device_register (&ka41_diag_led_device); +#ifdef CONFIG_VAX_RTC + vax_ds1287_rtc_register (VSA_CLOCK_BASE); +#endif retval = platform_device_register (&ka41_vsbus_device); if (!retval) { diff --git a/arch/vax/kernel/cpu_ka410.c b/arch/vax/kernel/cpu_ka410.c index e96c1b1..f8afab4 100644 --- a/arch/vax/kernel/cpu_ka410.c +++ b/arch/vax/kernel/cpu_ka410.c @@ -35,7 +35,6 @@ struct vax_mv mv_ka410 = { .post_vm_putchar = dz11_putchar, .post_vm_getchar = dz11_getchar, .cpu_type_str = ka410_cpu_type_str, - .clock_init = ka4x_clock_init, }; static struct cpu_match __CPU_MATCH cpumatch_ka410 = { @@ -48,3 +47,20 @@ static struct cpu_match __CPU_MATCH cpum .sidex_match = 0x00000000, }; +static int __init +ka410_platform_device_init (void) +{ + int retval = 0; + + if (!is_ka410()) + return -ENODEV; + +#ifdef CONFIG_VAX_RTC + vax_ds1287_rtc_register (VSA_CLOCK_BASE); +#endif + + return retval; +} + +arch_initcall (ka410_platform_device_init); + diff --git a/arch/vax/kernel/cpu_ka42.c b/arch/vax/kernel/cpu_ka42.c index eb33de3..d77c109 100644 --- a/arch/vax/kernel/cpu_ka42.c +++ b/arch/vax/kernel/cpu_ka42.c @@ -43,7 +43,6 @@ struct vax_mv mv_ka42 = { .post_vm_putchar = dz11_putchar, .post_vm_getchar = dz11_getchar, .cpu_type_str = ka42_cpu_type_str, - .clock_init = ka4x_clock_init, }; static struct cpu_match __CPU_MATCH cpu_match_ka42 = { @@ -72,6 +71,9 @@ static int __init ka42_platform_device_i return -ENODEV; platform_device_register(&ka42_diag_led_device); +#ifdef CONFIG_VAX_RTC + vax_ds1287_rtc_register (VSA_CLOCK_BASE); +#endif retval = platform_device_register(&ka42_vsbus_device); if (!retval) { diff --git a/arch/vax/kernel/cpu_ka43.c b/arch/vax/kernel/cpu_ka43.c index e06d5de..bcc96c4 100644 --- a/arch/vax/kernel/cpu_ka43.c +++ b/arch/vax/kernel/cpu_ka43.c @@ -223,7 +223,6 @@ struct vax_mv mv_ka43 = { .post_vm_getchar = dz11_getchar, .mcheck = ka43_mcheck, .cpu_type_str = ka43_cpu_type_str, - .clock_init = ka4x_clock_init, }; static struct cpu_match __CPU_MATCH cpumatch_ka43 = { @@ -251,6 +250,9 @@ static int __init ka43_platform_device_i return -ENODEV; platform_device_register(&ka43_diag_led_device); +#ifdef CONFIG_VAX_RTC + vax_ds1287_rtc_register (VSA_CLOCK_BASE); +#endif retval = platform_device_register(&ka43_vsbus_device); if (!retval) { diff --git a/arch/vax/kernel/cpu_ka46.c b/arch/vax/kernel/cpu_ka46.c index c85e0ba..d9faf33 100644 --- a/arch/vax/kernel/cpu_ka46.c +++ b/arch/vax/kernel/cpu_ka46.c @@ -128,7 +128,6 @@ struct vax_mv mv_ka46 = { .post_vm_getchar = dz11_getchar, .init_devices = ka46_init_devices, .cpu_type_str = ka46_cpu_type_str, - .clock_init = ka4x_clock_init, }; static struct cpu_match __CPU_MATCH cpumatch_ka46 = { @@ -156,6 +155,9 @@ static int __init ka46_platform_device_i return -ENODEV; platform_device_register(&ka46_diag_led_device); +#ifdef CONFIG_VAX_RTC + vax_ds1287_rtc_register (VSA_CLOCK_BASE); +#endif retval = platform_device_register(&ka46_vsbus_device); if (!retval) { diff --git a/arch/vax/kernel/cpu_ka48.c b/arch/vax/kernel/cpu_ka48.c index 39c6779..f72b1f0 100644 --- a/arch/vax/kernel/cpu_ka48.c +++ b/arch/vax/kernel/cpu_ka48.c @@ -124,7 +124,6 @@ struct vax_mv mv_ka48 = { .post_vm_getchar = dz11_getchar, .init_devices = ka48_init_devices, .cpu_type_str = ka48_cpu_type_str, - .clock_init = ka4x_clock_init, }; static struct cpu_match __CPU_MATCH cpumatch_ka48 = { @@ -147,6 +146,9 @@ static int __init ka48_platform_device_i if (!is_ka48()) return -ENODEV; +#ifdef CONFIG_VAX_RTC + vax_ds1287_rtc_register (VSA_CLOCK_BASE); +#endif retval = platform_device_register(&ka48_vsbus_device); if (!retval) { vsbus_add_fixed_device(&ka48_vsbus_device.dev, "lance", 0x200e0000, 1); diff --git a/arch/vax/kernel/cpu_ka49.c b/arch/vax/kernel/cpu_ka49.c index fd3e159..e7fc41e 100644 --- a/arch/vax/kernel/cpu_ka49.c +++ b/arch/vax/kernel/cpu_ka49.c @@ -134,7 +134,6 @@ struct vax_mv mv_ka49 = { .post_vm_getchar = dz11_getchar, .init_devices = ka49_init_devices, .cpu_type_str = ka49_cpu_type_str, - .clock_init = ka4x_clock_init, .nicr_required = 1, }; @@ -164,6 +163,9 @@ static int __init ka49_platform_device_i return -ENODEV; platform_device_register (&ka49_diag_led_device); +#ifdef CONFIG_VAX_RTC + vax_ds1287_rtc_register (VSA_CLOCK_BASE); +#endif retval = platform_device_register (&ka49_vsbus_device); if (!retval) { diff --git a/arch/vax/kernel/cpu_ka52.c b/arch/vax/kernel/cpu_ka52.c index 080b517..a428f40 100644 --- a/arch/vax/kernel/cpu_ka52.c +++ b/arch/vax/kernel/cpu_ka52.c @@ -62,7 +62,6 @@ struct vax_mv mv_ka52 = { .post_vm_putchar = ka46_48_49_prom_putchar /*ka52_postvm_putchar*/, .post_vm_getchar = dz11_getchar, .cpu_type_str = ka52_cpu_type_str, - //.clock_init = ka4x_clock_init, .mcheck = ka52_mcheck, .nicr_required = 1, }; @@ -92,6 +91,9 @@ static int __init ka52_platform_device_i return -ENODEV; platform_device_register (&ka52_diag_led_device); +#ifdef CONFIG_VAX_RTC + vax_no_rtc_register (); /* FIXME: RTC available? */ +#endif retval = platform_device_register (&ka52_vsbus_device); if (!retval) { diff --git a/arch/vax/kernel/cpu_ka55.c b/arch/vax/kernel/cpu_ka55.c index 931221f..82e3559 100644 --- a/arch/vax/kernel/cpu_ka55.c +++ b/arch/vax/kernel/cpu_ka55.c @@ -62,6 +62,6 @@ struct vax_mv mv_ka55 = { }; #warning "KA55 needs a struct cpumatch" - #warning "KA55 needs a platform_device_init function" +#warning "Needs a RTC" diff --git a/arch/vax/kernel/cpu_ka62.c b/arch/vax/kernel/cpu_ka62.c index 7326186..8876eb4 100644 --- a/arch/vax/kernel/cpu_ka62.c +++ b/arch/vax/kernel/cpu_ka62.c @@ -30,3 +30,19 @@ static struct cpu_match __CPU_MATCH cpum .sidex_addr = 0, }; +static int __init ka62_platform_device_init(void) +{ + int retval = 0; + + if (!is_ka62 ()) + return -ENODEV; + +#ifdef CONFIG_VAX_RTC + vax_no_rtc_register (); /* FIXME: RTC available? */ +#endif + + return retval; +} + +arch_initcall (ka62_platform_device_init); + diff --git a/arch/vax/kernel/cpu_ka630.c b/arch/vax/kernel/cpu_ka630.c index a28b608..03ee05e 100644 --- a/arch/vax/kernel/cpu_ka630.c +++ b/arch/vax/kernel/cpu_ka630.c @@ -46,3 +46,19 @@ static struct cpu_match __CPU_MATCH cpum .sidex_match = 0x00000000, }; +static int __init ka630_platform_device_init(void) +{ + int retval = 0; + + if (!is_ka630 ()) + return -ENODEV; + +#ifdef CONFIG_VAX_RTC + vax_no_rtc_register (); /* FIXME: RTC available? */ +#endif + + return retval; +} + +arch_initcall (ka630_platform_device_init); + diff --git a/arch/vax/kernel/cpu_ka640.c b/arch/vax/kernel/cpu_ka640.c index fed0bed..5c50552 100644 --- a/arch/vax/kernel/cpu_ka640.c +++ b/arch/vax/kernel/cpu_ka640.c @@ -61,3 +61,19 @@ static struct cpu_match __CPU_MATCH cpum (CVAX_Q22_SUBTYPE_KA640 << CVAX_Q22_SUBTYPE_SHIFT), }; +static int __init ka640_platform_device_init(void) +{ + int retval = 0; + + if (!is_ka630 ()) + return -ENODEV; + +#ifdef CONFIG_VAX_RTC + vax_no_rtc_register (); /* FIXME: RTC available? */ +#endif + + return retval; +} + +arch_initcall (ka640_platform_device_init); + diff --git a/arch/vax/kernel/cpu_ka650.c b/arch/vax/kernel/cpu_ka650.c index 636f828..d78ccc6 100644 --- a/arch/vax/kernel/cpu_ka650.c +++ b/arch/vax/kernel/cpu_ka650.c @@ -119,6 +119,9 @@ static int __init ka650_platform_device_ platform_device_register(&ka650_cqbic_device); platform_device_register(&ka650_iprcons_device); platform_device_register(&ka650_diag_led_device); +#ifdef CONFIG_VAX_RTC + vax_no_rtc_register (); /* FIXME: RTC available? */ +#endif return 0; } diff --git a/arch/vax/kernel/cpu_ka660.c b/arch/vax/kernel/cpu_ka660.c index 8428b33..d3db1e1 100644 --- a/arch/vax/kernel/cpu_ka660.c +++ b/arch/vax/kernel/cpu_ka660.c @@ -61,6 +61,9 @@ static int __init ka660_platform_device_ platform_device_register(&ka660_cqbic_device); platform_device_register(&ka660_iprcons_device); +#ifdef CONFIG_VAX_RTC + vax_no_rtc_register (); /* FIXME: RTC available? */ +#endif return 0; } diff --git a/arch/vax/kernel/cpu_vxt.c b/arch/vax/kernel/cpu_vxt.c index 7f3ef13..8a7c10d 100644 --- a/arch/vax/kernel/cpu_vxt.c +++ b/arch/vax/kernel/cpu_vxt.c @@ -68,6 +68,9 @@ static int __init vxt_platform_device_in return -ENODEV; platform_device_register (&vxt_diag_led_device); +#ifdef CONFIG_VAX_RTC + vax_no_rtc_register (); /* FIXME: RTC available? */ +#endif return 0; } diff --git a/arch/vax/kernel/rtc-generic.c b/arch/vax/kernel/rtc-generic.c new file mode 100644 index 0000000..8256664 --- /dev/null +++ b/arch/vax/kernel/rtc-generic.c @@ -0,0 +1,75 @@ +/* + * Support functions for VAX RTC access. Used by all cpu_xxx.c files. + */ + +#include <linux/m48t86.h> +#include <linux/platform_device.h> +#include <linux/io.h> + +/********************************************************************/ +/* Internal memory access helpers */ +/********************************************************************/ +/* + * Normal bus I/O. One byte (in the low byte) per longword. All data starts + * at bit #2, so we need to shift out the lower two bits. + */ +static volatile uint32_t __iomem *vax_rtc_io_base = NULL; + +static unsigned char +vax_rtc_bus_io_readb (unsigned long addr) +{ + unsigned char ret = 0; + + if (vax_rtc_io_base) + ret = (vax_rtc_io_base[addr] >> 2) & 0xff; + + printk (KERN_INFO "rtc_read: 0x%08lx --> %02x\n", (unsigned long) &vax_rtc_io_base[addr], ret); + + return ret; +} + +static void +vax_rtc_bus_io_writeb (unsigned char value, unsigned long addr) +{ + printk (KERN_INFO "rtc_write: 0x%02x --> 0x%08lx\n", value, (unsigned long) &vax_rtc_io_base[addr]); + + if (vax_rtc_io_base) + vax_rtc_io_base[addr] = value << 2; +} + +static struct m48t86_ops vax_rtc_bus_io_ops = { + .readb = vax_rtc_bus_io_readb, + .writeb = vax_rtc_bus_io_writeb, +}; + + +/********************************************************************/ +/* RTC-specific registration data */ +/********************************************************************/ +static struct platform_device vax_ds1287_rtc_platform_device = { + .name = "rtc-m48t86", + .id = -1, + .dev = { + .platform_data = &vax_rtc_bus_io_ops, + }, + .num_resources = 0, +}; + +/********************************************************************/ +/* External interface for use in cpu_xxx.c files */ +/********************************************************************/ +int +vax_ds1287_rtc_register (unsigned long phys_addr) +{ + vax_rtc_io_base = ioremap (phys_addr, 60 * 4); /* 60 I/O bytes of RTC, one per longword. */ + return platform_device_register (&vax_ds1287_rtc_platform_device); +} + +void +vax_no_rtc_register (void) +{ + printk (KERN_ERR "Warning: There is no RTC defined for your CPU.\n"); + printk (KERN_ERR "Please report to the VAX-Linux Mailing List at " + "<linux-vax@pergamentum.com>\n"); +} + diff --git a/include/asm-vax/clock.h b/include/asm-vax/clock.h index 83f0e0c..3aa896f 100644 --- a/include/asm-vax/clock.h +++ b/include/asm-vax/clock.h @@ -6,20 +6,22 @@ * Definitions for VAX clocks (interval counter and time-of-day) */ -/* structure of ICCS register (Interval Clock Control and Status) */ +/* Structure of ICCS register (Interval Clock Control and Status) */ -#define ICCS_ERROR (0x80000000) /* counter overflowed, INTERRUPT +#define ICCS_ERROR 0x80000000 /* Counter overflowed, INTERRUPT already set, write 1 to clear */ -#define ICCS_INTERRUPT (0x00000080) /* Set when ICR overflows, write 1 +#define ICCS_INTERRUPT 0x00000080 /* Set when ICR overflows, write 1 to clear */ -#define ICCS_TRANSFER (0x00000040) /* Copy NICR to ICR */ -#define ICCS_SINGLESTEP (0x00000020) /* increment Interval Count Register +#define ICCS_TRANSFER 0x00000040 /* Copy NICR to ICR */ +#define ICCS_SINGLESTEP 0x00000020 /* Increment Interval Count Register (ICR) by one, only if RUN is 0 */ -#define ICCS_INTENABLE (0x00000010) /* enable clock interrupts */ -#define ICCS_RUN (0x00000001) /* enable counter */ +#define ICCS_INTENABLE 0x00000010 /* Enable clock interrupts */ +#define ICCS_RUN 0x00000001 /* Enable counter */ -/* prototypes for clock handling functions in arch/vax/clock.c */ -void generic_clock_init(void); -void ka4x_clock_init(void); + +/* Prototypes for RTC register functions in ./arch/vax/rtc-generic.c */ + +extern int vax_ds1287_rtc_register (unsigned long base_address); +extern void vax_no_rtc_register (void); #endif /* _VAX_CLOCK_H_ */ diff --git a/include/asm-vax/mv.h b/include/asm-vax/mv.h index 6bdcd28..983ac38 100644 --- a/include/asm-vax/mv.h +++ b/include/asm-vax/mv.h @@ -40,9 +40,6 @@ struct vax_mv { const char * (*cpu_type_str)(void); - void (*clock_init)(void); /* Called by time_init() to set up RTC */ - unsigned int *clock_base; /* Address of clock page for vsbus RTC */ - unsigned int sidex; /* If not available, it's set to 0 */ /* Flags for very CPU-specific features */ -- Jan-Benedict Glaw jbglaw@lug-owl.de . +49-172-7608481 _ O _ "Eine Freie Meinung in einem Freien Kopf | Gegen Zensur | Gegen Krieg _ _ O für einen Freien Staat voll Freier Bürger" | im Internet! | im Irak! O O O ret = do_actions((curr | FREE_SPEECH) & ~(NEW_COPYRIGHT_LAW | DRM | TCPA)); _______________________________________________ Linux-Vax mailing list Linux-Vax@pergamentum.com http://www.pergamentum.com/mailman/listinfo/linux-vax
Teilnehmer (1)
-
Jan-Benedict Glaw