diff options
| -rw-r--r-- | arch/x86/include/asm/fixmap.h | 4 | ||||
| -rw-r--r-- | arch/x86/include/asm/mrst-vrtc.h | 9 | ||||
| -rw-r--r-- | arch/x86/include/asm/mrst.h | 10 | ||||
| -rw-r--r-- | arch/x86/platform/mrst/Makefile | 1 | ||||
| -rw-r--r-- | arch/x86/platform/mrst/mrst.c | 6 | ||||
| -rw-r--r-- | arch/x86/platform/mrst/vrtc.c | 120 |
6 files changed, 143 insertions, 7 deletions
diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h index 4d293dced62f..139591a933f6 100644 --- a/arch/x86/include/asm/fixmap.h +++ b/arch/x86/include/asm/fixmap.h | |||
| @@ -117,6 +117,10 @@ enum fixed_addresses { | |||
| 117 | FIX_TEXT_POKE1, /* reserve 2 pages for text_poke() */ | 117 | FIX_TEXT_POKE1, /* reserve 2 pages for text_poke() */ |
| 118 | FIX_TEXT_POKE0, /* first page is last, because allocation is backward */ | 118 | FIX_TEXT_POKE0, /* first page is last, because allocation is backward */ |
| 119 | __end_of_permanent_fixed_addresses, | 119 | __end_of_permanent_fixed_addresses, |
| 120 | |||
| 121 | #ifdef CONFIG_X86_MRST | ||
| 122 | FIX_LNW_VRTC, | ||
| 123 | #endif | ||
| 120 | /* | 124 | /* |
| 121 | * 256 temporary boot-time mappings, used by early_ioremap(), | 125 | * 256 temporary boot-time mappings, used by early_ioremap(), |
| 122 | * before ioremap() is functional. | 126 | * before ioremap() is functional. |
diff --git a/arch/x86/include/asm/mrst-vrtc.h b/arch/x86/include/asm/mrst-vrtc.h new file mode 100644 index 000000000000..73668abdbedf --- /dev/null +++ b/arch/x86/include/asm/mrst-vrtc.h | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | #ifndef _MRST_VRTC_H | ||
| 2 | #define _MRST_VRTC_H | ||
| 3 | |||
| 4 | extern unsigned char vrtc_cmos_read(unsigned char reg); | ||
| 5 | extern void vrtc_cmos_write(unsigned char val, unsigned char reg); | ||
| 6 | extern unsigned long vrtc_get_time(void); | ||
| 7 | extern int vrtc_set_mmss(unsigned long nowtime); | ||
| 8 | |||
| 9 | #endif | ||
diff --git a/arch/x86/include/asm/mrst.h b/arch/x86/include/asm/mrst.h index 283debd29fc0..719f00b28ff5 100644 --- a/arch/x86/include/asm/mrst.h +++ b/arch/x86/include/asm/mrst.h | |||
| @@ -14,7 +14,9 @@ | |||
| 14 | #include <linux/sfi.h> | 14 | #include <linux/sfi.h> |
| 15 | 15 | ||
| 16 | extern int pci_mrst_init(void); | 16 | extern int pci_mrst_init(void); |
| 17 | int __init sfi_parse_mrtc(struct sfi_table_header *table); | 17 | extern int __init sfi_parse_mrtc(struct sfi_table_header *table); |
| 18 | extern int sfi_mrtc_num; | ||
| 19 | extern struct sfi_rtc_table_entry sfi_mrtc_array[]; | ||
| 18 | 20 | ||
| 19 | /* | 21 | /* |
| 20 | * Medfield is the follow-up of Moorestown, it combines two chip solution into | 22 | * Medfield is the follow-up of Moorestown, it combines two chip solution into |
| @@ -54,4 +56,10 @@ extern void hsu_early_console_init(void); | |||
| 54 | extern void intel_scu_devices_create(void); | 56 | extern void intel_scu_devices_create(void); |
| 55 | extern void intel_scu_devices_destroy(void); | 57 | extern void intel_scu_devices_destroy(void); |
| 56 | 58 | ||
| 59 | /* VRTC timer */ | ||
| 60 | #define MRST_VRTC_MAP_SZ (1024) | ||
| 61 | /*#define MRST_VRTC_PGOFFSET (0xc00) */ | ||
| 62 | |||
| 63 | extern void mrst_rtc_init(void); | ||
| 64 | |||
| 57 | #endif /* _ASM_X86_MRST_H */ | 65 | #endif /* _ASM_X86_MRST_H */ |
diff --git a/arch/x86/platform/mrst/Makefile b/arch/x86/platform/mrst/Makefile index efbbc552fa95..4d3e256780be 100644 --- a/arch/x86/platform/mrst/Makefile +++ b/arch/x86/platform/mrst/Makefile | |||
| @@ -1 +1,2 @@ | |||
| 1 | obj-$(CONFIG_X86_MRST) += mrst.o | 1 | obj-$(CONFIG_X86_MRST) += mrst.o |
| 2 | obj-$(CONFIG_X86_MRST) += vrtc.o | ||
diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c index c727d97f7f31..42a0351f302c 100644 --- a/arch/x86/platform/mrst/mrst.c +++ b/arch/x86/platform/mrst/mrst.c | |||
| @@ -37,7 +37,6 @@ | |||
| 37 | #include <asm/apb_timer.h> | 37 | #include <asm/apb_timer.h> |
| 38 | #include <asm/reboot.h> | 38 | #include <asm/reboot.h> |
| 39 | 39 | ||
| 40 | |||
| 41 | /* | 40 | /* |
| 42 | * the clockevent devices on Moorestown/Medfield can be APBT or LAPIC clock, | 41 | * the clockevent devices on Moorestown/Medfield can be APBT or LAPIC clock, |
| 43 | * cmdline option x86_mrst_timer can be used to override the configuration | 42 | * cmdline option x86_mrst_timer can be used to override the configuration |
| @@ -242,11 +241,6 @@ void __init mrst_time_init(void) | |||
| 242 | apbt_time_init(); | 241 | apbt_time_init(); |
| 243 | } | 242 | } |
| 244 | 243 | ||
| 245 | void __init mrst_rtc_init(void) | ||
| 246 | { | ||
| 247 | sfi_table_parse(SFI_SIG_MRTC, NULL, NULL, sfi_parse_mrtc); | ||
| 248 | } | ||
| 249 | |||
| 250 | void __cpuinit mrst_arch_setup(void) | 244 | void __cpuinit mrst_arch_setup(void) |
| 251 | { | 245 | { |
| 252 | if (boot_cpu_data.x86 == 6 && boot_cpu_data.x86_model == 0x27) | 246 | if (boot_cpu_data.x86 == 6 && boot_cpu_data.x86_model == 0x27) |
diff --git a/arch/x86/platform/mrst/vrtc.c b/arch/x86/platform/mrst/vrtc.c new file mode 100644 index 000000000000..4944bd521d2c --- /dev/null +++ b/arch/x86/platform/mrst/vrtc.c | |||
| @@ -0,0 +1,120 @@ | |||
| 1 | /* | ||
| 2 | * vrtc.c: Driver for virtual RTC device on Intel MID platform | ||
| 3 | * | ||
| 4 | * (C) Copyright 2009 Intel Corporation | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU General Public License | ||
| 8 | * as published by the Free Software Foundation; version 2 | ||
| 9 | * of the License. | ||
| 10 | * | ||
| 11 | * Note: | ||
| 12 | * VRTC is emulated by system controller firmware, the real HW | ||
| 13 | * RTC is located in the PMIC device. SCU FW shadows PMIC RTC | ||
| 14 | * in a memory mapped IO space that is visible to the host IA | ||
| 15 | * processor. | ||
| 16 | * | ||
| 17 | * This driver is based on RTC CMOS driver. | ||
| 18 | */ | ||
| 19 | |||
| 20 | #include <linux/kernel.h> | ||
| 21 | #include <linux/init.h> | ||
| 22 | #include <linux/sfi.h> | ||
| 23 | |||
| 24 | #include <asm/mrst.h> | ||
| 25 | #include <asm/mrst-vrtc.h> | ||
| 26 | #include <asm/time.h> | ||
| 27 | #include <asm/fixmap.h> | ||
| 28 | |||
| 29 | static unsigned char __iomem *vrtc_virt_base; | ||
| 30 | |||
| 31 | unsigned char vrtc_cmos_read(unsigned char reg) | ||
| 32 | { | ||
| 33 | unsigned char retval; | ||
| 34 | |||
| 35 | /* vRTC's registers range from 0x0 to 0xD */ | ||
| 36 | if (reg > 0xd || !vrtc_virt_base) | ||
| 37 | return 0xff; | ||
| 38 | |||
| 39 | lock_cmos_prefix(reg); | ||
| 40 | retval = __raw_readb(vrtc_virt_base + (reg << 2)); | ||
| 41 | lock_cmos_suffix(reg); | ||
| 42 | return retval; | ||
| 43 | } | ||
| 44 | EXPORT_SYMBOL_GPL(vrtc_cmos_read); | ||
| 45 | |||
| 46 | void vrtc_cmos_write(unsigned char val, unsigned char reg) | ||
| 47 | { | ||
| 48 | if (reg > 0xd || !vrtc_virt_base) | ||
| 49 | return; | ||
| 50 | |||
| 51 | lock_cmos_prefix(reg); | ||
| 52 | __raw_writeb(val, vrtc_virt_base + (reg << 2)); | ||
| 53 | lock_cmos_suffix(reg); | ||
| 54 | } | ||
| 55 | EXPORT_SYMBOL_GPL(vrtc_cmos_write); | ||
| 56 | |||
| 57 | unsigned long vrtc_get_time(void) | ||
| 58 | { | ||
| 59 | u8 sec, min, hour, mday, mon; | ||
| 60 | u32 year; | ||
| 61 | |||
| 62 | while ((vrtc_cmos_read(RTC_FREQ_SELECT) & RTC_UIP)) | ||
| 63 | cpu_relax(); | ||
| 64 | |||
| 65 | sec = vrtc_cmos_read(RTC_SECONDS); | ||
| 66 | min = vrtc_cmos_read(RTC_MINUTES); | ||
| 67 | hour = vrtc_cmos_read(RTC_HOURS); | ||
| 68 | mday = vrtc_cmos_read(RTC_DAY_OF_MONTH); | ||
| 69 | mon = vrtc_cmos_read(RTC_MONTH); | ||
| 70 | year = vrtc_cmos_read(RTC_YEAR); | ||
| 71 | |||
| 72 | /* vRTC YEAR reg contains the offset to 1960 */ | ||
| 73 | year += 1960; | ||
| 74 | |||
| 75 | printk(KERN_INFO "vRTC: sec: %d min: %d hour: %d day: %d " | ||
| 76 | "mon: %d year: %d\n", sec, min, hour, mday, mon, year); | ||
| 77 | |||
| 78 | return mktime(year, mon, mday, hour, min, sec); | ||
| 79 | } | ||
| 80 | |||
| 81 | /* Only care about the minutes and seconds */ | ||
| 82 | int vrtc_set_mmss(unsigned long nowtime) | ||
| 83 | { | ||
| 84 | int real_sec, real_min; | ||
| 85 | int vrtc_min; | ||
| 86 | |||
| 87 | vrtc_min = vrtc_cmos_read(RTC_MINUTES); | ||
| 88 | |||
| 89 | real_sec = nowtime % 60; | ||
| 90 | real_min = nowtime / 60; | ||
| 91 | if (((abs(real_min - vrtc_min) + 15)/30) & 1) | ||
| 92 | real_min += 30; | ||
| 93 | real_min %= 60; | ||
| 94 | |||
| 95 | vrtc_cmos_write(real_sec, RTC_SECONDS); | ||
| 96 | vrtc_cmos_write(real_min, RTC_MINUTES); | ||
| 97 | return 0; | ||
| 98 | } | ||
| 99 | |||
| 100 | void __init mrst_rtc_init(void) | ||
| 101 | { | ||
| 102 | unsigned long rtc_paddr; | ||
| 103 | void __iomem *virt_base; | ||
| 104 | |||
| 105 | sfi_table_parse(SFI_SIG_MRTC, NULL, NULL, sfi_parse_mrtc); | ||
| 106 | if (!sfi_mrtc_num) | ||
| 107 | return; | ||
| 108 | |||
| 109 | rtc_paddr = sfi_mrtc_array[0].phys_addr; | ||
