Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/kyle/rtc-parisc
Browse files Browse the repository at this point in the history
* git://git.kernel.org/pub/scm/linux/kernel/git/kyle/rtc-parisc:
  powerpc/ps3: Add rtc-ps3
  powerpc: Hook up rtc-generic, and kill rtc-ppc
  m68k: Hook up rtc-generic
  parisc: rtc: Rename rtc-parisc to rtc-generic
  parisc: rtc: Add missing module alias
  parisc: rtc: platform_driver_probe() fixups
  parisc: rtc: get_rtc_time() returns unsigned int
  • Loading branch information
torvalds committed Apr 3, 2009
2 parents 03c3fa0 + 0b5f037 commit bad6a5c
Show file tree
Hide file tree
Showing 16 changed files with 267 additions and 195 deletions.
7 changes: 5 additions & 2 deletions arch/m68k/include/asm/rtc.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ static inline unsigned int get_rtc_time(struct rtc_time *time)
* RTC has RTC_DAY_OF_WEEK, we ignore it, as it is only updated
* by the RTC when initially set to a non-zero value.
*/
mach_hwclk(0, time);
if (mach_hwclk)
mach_hwclk(0, time);
return RTC_24H;
}

static inline int set_rtc_time(struct rtc_time *time)
{
return mach_hwclk(1, time);
if (mach_hwclk)
return mach_hwclk(1, time);
return -EINVAL;
}

static inline unsigned int get_rtc_ss(void)
Expand Down
18 changes: 18 additions & 0 deletions arch/m68k/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/rtc.h>
#include <linux/platform_device.h>

#include <asm/machdep.h>
#include <asm/io.h>
Expand Down Expand Up @@ -159,3 +160,20 @@ int do_settimeofday(struct timespec *tv)
}

EXPORT_SYMBOL(do_settimeofday);


static int __init rtc_init(void)
{
struct platform_device *pdev;

if (!mach_hwclk)
return -ENODEV;

pdev = platform_device_register_simple("rtc-generic", -1, NULL, 0);
if (IS_ERR(pdev))
return PTR_ERR(pdev);

return 0;
}

module_init(rtc_init);
2 changes: 1 addition & 1 deletion arch/parisc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ config PARISC
select HAVE_IDE
select HAVE_OPROFILE
select RTC_CLASS
select RTC_DRV_PARISC
select RTC_DRV_GENERIC
select INIT_ALL_POSSIBLE
help
The PA-RISC microprocessor is designed by Hewlett-Packard and used
Expand Down
6 changes: 3 additions & 3 deletions arch/parisc/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,14 @@ void __init start_cpu_itimer(void)
per_cpu(cpu_data, cpu).it_value = next_tick;
}

static struct platform_device rtc_parisc_dev = {
.name = "rtc-parisc",
static struct platform_device rtc_generic_dev = {
.name = "rtc-generic",
.id = -1,
};

static int __init rtc_init(void)
{
if (platform_device_register(&rtc_parisc_dev) < 0)
if (platform_device_register(&rtc_generic_dev) < 0)
printk(KERN_ERR "unable to register rtc device...\n");

/* not necessarily an error */
Expand Down
3 changes: 3 additions & 0 deletions arch/powerpc/include/asm/ps3.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ enum ps3_param_av_multi_out {

enum ps3_param_av_multi_out ps3_os_area_get_av_multi_out(void);

extern u64 ps3_os_area_get_rtc_diff(void);
extern void ps3_os_area_set_rtc_diff(u64 rtc_diff);

/* dma routines */

enum ps3_dma_page_size {
Expand Down
16 changes: 16 additions & 0 deletions arch/powerpc/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -1127,3 +1127,19 @@ void div128_by_32(u64 dividend_high, u64 dividend_low,
dr->result_low = ((u64)y << 32) + z;

}

static int __init rtc_init(void)
{
struct platform_device *pdev;

if (!ppc_md.get_rtc_time)
return -ENODEV;

pdev = platform_device_register_simple("rtc-generic", -1, NULL, 0);
if (IS_ERR(pdev))
return PTR_ERR(pdev);

return 0;
}

module_init(rtc_init);
2 changes: 2 additions & 0 deletions arch/powerpc/platforms/ps3/os-area.c
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@ u64 ps3_os_area_get_rtc_diff(void)
{
return saved_params.rtc_diff;
}
EXPORT_SYMBOL(ps3_os_area_get_rtc_diff);

/**
* ps3_os_area_set_rtc_diff - Set the rtc diff value.
Expand All @@ -823,6 +824,7 @@ void ps3_os_area_set_rtc_diff(u64 rtc_diff)
os_area_queue_work();
}
}
EXPORT_SYMBOL(ps3_os_area_set_rtc_diff);

/**
* ps3_os_area_get_av_multi_out - Returns the default video mode.
Expand Down
2 changes: 0 additions & 2 deletions arch/powerpc/platforms/ps3/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ int ps3_set_rtc_time(struct rtc_time *time);

void __init ps3_os_area_save_params(void);
void __init ps3_os_area_init(void);
u64 ps3_os_area_get_rtc_diff(void);
void ps3_os_area_set_rtc_diff(u64 rtc_diff);

/* spu */

Expand Down
2 changes: 0 additions & 2 deletions arch/powerpc/platforms/ps3/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,6 @@ define_machine(ps3) {
.init_IRQ = ps3_init_IRQ,
.panic = ps3_panic,
.get_boot_time = ps3_get_boot_time,
.set_rtc_time = ps3_set_rtc_time,
.get_rtc_time = ps3_get_rtc_time,
.set_dabr = ps3_set_dabr,
.calibrate_decr = ps3_calibrate_decr,
.progress = ps3_progress,
Expand Down
26 changes: 12 additions & 14 deletions arch/powerpc/platforms/ps3/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

#include <linux/kernel.h>
#include <linux/platform_device.h>

#include <asm/rtc.h>
#include <asm/lv1call.h>
Expand Down Expand Up @@ -74,23 +75,20 @@ static u64 read_rtc(void)
return rtc_val;
}

int ps3_set_rtc_time(struct rtc_time *tm)
unsigned long __init ps3_get_boot_time(void)
{
u64 now = mktime(tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);

ps3_os_area_set_rtc_diff(now - read_rtc());
return 0;
return read_rtc() + ps3_os_area_get_rtc_diff();
}

void ps3_get_rtc_time(struct rtc_time *tm)
static int __init ps3_rtc_init(void)
{
to_tm(read_rtc() + ps3_os_area_get_rtc_diff(), tm);
tm->tm_year -= 1900;
tm->tm_mon -= 1;
}
struct platform_device *pdev;

unsigned long __init ps3_get_boot_time(void)
{
return read_rtc() + ps3_os_area_get_rtc_diff();
pdev = platform_device_register_simple("rtc-ps3", -1, NULL, 0);
if (IS_ERR(pdev))
return PTR_ERR(pdev);

return 0;
}

module_init(ps3_rtc_init);
31 changes: 17 additions & 14 deletions drivers/rtc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -688,22 +688,16 @@ config RTC_DRV_RS5C313
help
If you say yes here you get support for the Ricoh RS5C313 RTC chips.

config RTC_DRV_PARISC
tristate "PA-RISC firmware RTC support"
depends on PARISC
help
Say Y or M here to enable RTC support on PA-RISC systems using
firmware calls. If you do not know what you are doing, you should
config RTC_DRV_GENERIC
tristate "Generic RTC support"
# Please consider writing a new RTC driver instead of using the generic
# RTC abstraction
depends on PARISC || M68K || PPC
help
Say Y or M here to enable RTC support on systems using the generic
RTC abstraction. If you do not know what you are doing, you should
just say Y.

config RTC_DRV_PPC
tristate "PowerPC machine dependent RTC support"
depends on PPC
help
The PowerPC kernel has machine-specific functions for accessing
the RTC. This exposes that functionality through the generic RTC
class.

config RTC_DRV_PXA
tristate "PXA27x/PXA3xx"
depends on ARCH_PXA
Expand Down Expand Up @@ -747,4 +741,13 @@ config RTC_DRV_MV
This driver can also be built as a module. If so, the module
will be called rtc-mv.

config RTC_DRV_PS3
tristate "PS3 RTC"
depends on PPC_PS3
help
If you say yes here you will get support for the RTC on PS3.

This driver can also be built as a module. If so, the module
will be called rtc-ps3.

endif # RTC_CLASS
4 changes: 2 additions & 2 deletions drivers/rtc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o
obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o
obj-$(CONFIG_RTC_DRV_PL030) += rtc-pl030.o
obj-$(CONFIG_RTC_DRV_PL031) += rtc-pl031.o
obj-$(CONFIG_RTC_DRV_PARISC) += rtc-parisc.o
obj-$(CONFIG_RTC_DRV_PPC) += rtc-ppc.o
obj-$(CONFIG_RTC_DRV_GENERIC) += rtc-generic.o
obj-$(CONFIG_RTC_DRV_PXA) += rtc-pxa.o
obj-$(CONFIG_RTC_DRV_R9701) += rtc-r9701.o
obj-$(CONFIG_RTC_DRV_RS5C313) += rtc-rs5c313.o
Expand All @@ -77,3 +76,4 @@ obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o
obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o
obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o
obj-$(CONFIG_RTC_DRV_PCF50633) += rtc-pcf50633.o
obj-$(CONFIG_RTC_DRV_PS3) += rtc-ps3.o
84 changes: 84 additions & 0 deletions drivers/rtc/rtc-generic.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/* rtc-generic: RTC driver using the generic RTC abstraction
*
* Copyright (C) 2008 Kyle McMartin <kyle@mcmartin.ca>
*/

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/time.h>
#include <linux/platform_device.h>
#include <linux/rtc.h>

#include <asm/rtc.h>

static int generic_get_time(struct device *dev, struct rtc_time *tm)
{
unsigned int ret = get_rtc_time(tm);

if (ret & RTC_BATT_BAD)
return -EOPNOTSUPP;

return rtc_valid_tm(tm);
}

static int generic_set_time(struct device *dev, struct rtc_time *tm)
{
if (set_rtc_time(tm) < 0)
return -EOPNOTSUPP;

return 0;
}

static const struct rtc_class_ops generic_rtc_ops = {
.read_time = generic_get_time,
.set_time = generic_set_time,
};

static int __init generic_rtc_probe(struct platform_device *dev)
{
struct rtc_device *rtc;

rtc = rtc_device_register("rtc-generic", &dev->dev, &generic_rtc_ops,
THIS_MODULE);
if (IS_ERR(rtc))
return PTR_ERR(rtc);

platform_set_drvdata(dev, rtc);

return 0;
}

static int __exit generic_rtc_remove(struct platform_device *dev)
{
struct rtc_device *rtc = platform_get_drvdata(dev);

rtc_device_unregister(rtc);

return 0;
}

static struct platform_driver generic_rtc_driver = {
.driver = {
.name = "rtc-generic",
.owner = THIS_MODULE,
},
.remove = __exit_p(generic_rtc_remove),
};

static int __init generic_rtc_init(void)
{
return platform_driver_probe(&generic_rtc_driver, generic_rtc_probe);
}

static void __exit generic_rtc_fini(void)
{
platform_driver_unregister(&generic_rtc_driver);
}

module_init(generic_rtc_init);
module_exit(generic_rtc_fini);

MODULE_AUTHOR("Kyle McMartin <kyle@mcmartin.ca>");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Generic RTC driver");
MODULE_ALIAS("platform:rtc-generic");
Loading

0 comments on commit bad6a5c

Please sign in to comment.