Commit bad6a5c0 authored by Linus Torvalds's avatar Linus Torvalds

Merge git://git.kernel.org/pub/scm/linux/kernel/git/kyle/rtc-parisc

* 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
parents 03c3fa0a 0b5f037a
......@@ -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)
......
......@@ -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>
......@@ -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);
......@@ -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
......
......@@ -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 */
......
......@@ -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 {
......
......@@ -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);
......@@ -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.
......@@ -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.
......
......@@ -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 */
......
......@@ -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,
......
......@@ -19,6 +19,7 @@
*/
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <asm/rtc.h>
#include <asm/lv1call.h>
......@@ -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);
......@@ -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
......@@ -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
......@@ -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
......@@ -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
/* rtc-parisc: RTC for HP PA-RISC firmware
/* rtc-generic: RTC driver using the generic RTC abstraction
*
* Copyright (C) 2008 Kyle McMartin <kyle@mcmartin.ca>
*/
......@@ -11,11 +11,9 @@
#include <asm/rtc.h>
static int parisc_get_time(struct device *dev, struct rtc_time *tm)
static int generic_get_time(struct device *dev, struct rtc_time *tm)
{
unsigned long ret;
ret = get_rtc_time(tm);
unsigned int ret = get_rtc_time(tm);
if (ret & RTC_BATT_BAD)
return -EOPNOTSUPP;
......@@ -23,7 +21,7 @@ static int parisc_get_time(struct device *dev, struct rtc_time *tm)
return rtc_valid_tm(tm);
}
static int parisc_set_time(struct device *dev, struct rtc_time *tm)
static int generic_set_time(struct device *dev, struct rtc_time *tm)
{
if (set_rtc_time(tm) < 0)
return -EOPNOTSUPP;
......@@ -31,16 +29,16 @@ static int parisc_set_time(struct device *dev, struct rtc_time *tm)
return 0;
}
static const struct rtc_class_ops parisc_rtc_ops = {
.read_time = parisc_get_time,
.set_time = parisc_set_time,
static const struct rtc_class_ops generic_rtc_ops = {
.read_time = generic_get_time,
.set_time = generic_set_time,
};
static int __init parisc_rtc_probe(struct platform_device *dev)
static int __init generic_rtc_probe(struct platform_device *dev)
{
struct rtc_device *rtc;
rtc = rtc_device_register("rtc-parisc", &dev->dev, &parisc_rtc_ops,
rtc = rtc_device_register("rtc-generic", &dev->dev, &generic_rtc_ops,
THIS_MODULE);
if (IS_ERR(rtc))
return PTR_ERR(rtc);
......@@ -50,7 +48,7 @@ static int __init parisc_rtc_probe(struct platform_device *dev)
return 0;
}
static int __exit parisc_rtc_remove(struct platform_device *dev)
static int __exit generic_rtc_remove(struct platform_device *dev)
{
struct rtc_device *rtc = platform_get_drvdata(dev);
......@@ -59,28 +57,28 @@ static int __exit parisc_rtc_remove(struct platform_device *dev)
return 0;
}
static struct platform_driver parisc_rtc_driver = {
static struct platform_driver generic_rtc_driver = {
.driver = {
.name = "rtc-parisc",
.name = "rtc-generic",
.owner = THIS_MODULE,
},
.probe = parisc_rtc_probe,
.remove = __devexit_p(parisc_rtc_remove),
.remove = __exit_p(generic_rtc_remove),
};
static int __init parisc_rtc_init(void)
static int __init generic_rtc_init(void)
{
return platform_driver_probe(&parisc_rtc_driver, parisc_rtc_probe);
return platform_driver_probe(&generic_rtc_driver, generic_rtc_probe);
}
static void __exit parisc_rtc_fini(void)
static void __exit generic_rtc_fini(void)
{
platform_driver_unregister(&parisc_rtc_driver);
platform_driver_unregister(&generic_rtc_driver);
}
module_init(parisc_rtc_init);
module_exit(parisc_rtc_fini);
module_init(generic_rtc_init);
module_exit(generic_rtc_fini);
MODULE_AUTHOR("Kyle McMartin <kyle@mcmartin.ca>");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("HP PA-RISC RTC driver");
MODULE_DESCRIPTION("Generic RTC driver");
MODULE_ALIAS("platform:rtc-generic");
/*
* RTC driver for ppc_md RTC functions
*
* © 2007 Red Hat, Inc.
*
* Author: David Woodhouse <dwmw2@infradead.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/err.h>
#include <linux/rtc.h>
#include <linux/platform_device.h>
#include <asm/machdep.h>
static int ppc_rtc_read_time(struct device *dev, struct rtc_time *tm)
{
ppc_md.get_rtc_time(tm);
return 0;
}
static int ppc_rtc_set_time(struct device *dev, struct rtc_time *tm)
{
return ppc_md.set_rtc_time(tm);
}
static const struct rtc_class_ops ppc_rtc_ops = {
.set_time = ppc_rtc_set_time,
.read_time = ppc_rtc_read_time,
};
static struct rtc_device *rtc;
static struct platform_device *ppc_rtc_pdev;
static int __init ppc_rtc_init(void)
{
if (!ppc_md.get_rtc_time || !ppc_md.set_rtc_time)
return -ENODEV;
ppc_rtc_pdev = platform_device_register_simple("ppc-rtc", 0, NULL, 0);
if (IS_ERR(ppc_rtc_pdev))
return PTR_ERR(ppc_rtc_pdev);
rtc = rtc_device_register("ppc_md", &ppc_rtc_pdev->dev,
&ppc_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc)) {
platform_device_unregister(ppc_rtc_pdev);
return PTR_ERR(rtc);
}
return 0;
}
static void __exit ppc_rtc_exit(void)
{
rtc_device_unregister(rtc);
platform_device_unregister(ppc_rtc_pdev);
}
module_init(ppc_rtc_init);
module_exit(ppc_rtc_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("David Woodhouse <dwmw2@infradead.org>");
MODULE_DESCRIPTION("Generic RTC class driver for PowerPC");
/*
* PS3 RTC Driver
*
* Copyright 2009 Sony Corporation
*
* 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; version 2 of the License.
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/rtc.h>
#include <asm/lv1call.h>
#include <asm/ps3.h>
static u64 read_rtc(void)
{
int result;
u64 rtc_val;
u64 tb_val;
result = lv1_get_rtc(&rtc_val, &tb_val);
BUG_ON(result);
return rtc_val;
}
static int ps3_get_time(struct device *dev, struct rtc_time *tm)
{
rtc_time_to_tm(read_rtc() + ps3_os_area_get_rtc_diff(), tm);
return rtc_valid_tm(tm);
}
static int ps3_set_time(struct device *dev, struct rtc_time *tm)
{
unsigned long now;
rtc_tm_to_time(tm, &now);
ps3_os_area_set_rtc_diff(now - read_rtc());
return 0;
}
static const struct rtc_class_ops ps3_rtc_ops = {
.read_time = ps3_get_time,
.set_time = ps3_set_time,
};
static int __init ps3_rtc_probe(struct platform_device *dev)
{
struct rtc_device *rtc;
rtc = rtc_device_register("rtc-ps3", &dev->dev, &ps3_rtc_ops,
THIS_MODULE);
if (IS_ERR(rtc))
return PTR_ERR(rtc);
platform_set_drvdata(dev, rtc);
return 0;
}
static int __exit ps3_rtc_remove(struct platform_device *dev)
{
rtc_device_unregister(platform_get_drvdata(dev));
return 0;
}
static struct platform_driver ps3_rtc_driver = {
.driver = {
.name = "rtc-ps3",
.owner = THIS_MODULE,
},
.remove = __exit_p(ps3_rtc_remove),
};
static int __init ps3_rtc_init(void)
{
return platform_driver_probe(&ps3_rtc_driver, ps3_rtc_probe);
}
static void __exit ps3_rtc_fini(void)
{
platform_driver_unregister(&ps3_rtc_driver);
}
module_init(ps3_rtc_init);
module_exit(ps3_rtc_fini);
MODULE_AUTHOR("Sony Corporation");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("ps3 RTC driver");
MODULE_ALIAS("platform:rtc-ps3");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment