diff options
author | Krzysztof Helt <krzysztof.h1@wp.pl> | 2008-10-29 18:35:24 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-10-29 18:35:24 -0400 |
commit | 12a9ee3cce256ae0f178d604f2c8764fb2942cfe (patch) | |
tree | 64a3f5bc9185af7b4656894ed57b387d91d44626 /arch/sparc64 | |
parent | be376649344ba2c3d00021f8bbf64392aa01ad55 (diff) |
rtc-m48t59: shift zero year to 1968 on sparc (rev 2)
Shift the first year to 1968 for Sun SPARC machines.
Move this logic from platform specific files to rtc driver
as this fixes problems with calculating a century bit.
Signed-off-by: Krzysztof Helt <krzysztof.h1@wp.pl>
Tested-by: Alexander Beregalov
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc64')
-rw-r--r-- | arch/sparc64/kernel/time.c | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c index 80d71a5ce1e3..dfd1b33e770a 100644 --- a/arch/sparc64/kernel/time.c +++ b/arch/sparc64/kernel/time.c | |||
@@ -503,39 +503,16 @@ static struct of_platform_driver bq4802_driver = { | |||
503 | static unsigned char mostek_read_byte(struct device *dev, u32 ofs) | 503 | static unsigned char mostek_read_byte(struct device *dev, u32 ofs) |
504 | { | 504 | { |
505 | struct platform_device *pdev = to_platform_device(dev); | 505 | struct platform_device *pdev = to_platform_device(dev); |
506 | struct m48t59_plat_data *pdata = pdev->dev.platform_data; | 506 | void __iomem *regs = (void __iomem *) pdev->resource[0].start; |
507 | void __iomem *regs; | 507 | |
508 | unsigned char val; | 508 | return readb(regs + ofs); |
509 | |||
510 | regs = (void __iomem *) pdev->resource[0].start; | ||
511 | val = readb(regs + ofs); | ||
512 | |||
513 | /* the year 0 is 1968 */ | ||
514 | if (ofs == pdata->offset + M48T59_YEAR) { | ||
515 | val += 0x68; | ||
516 | if ((val & 0xf) > 9) | ||
517 | val += 6; | ||
518 | } | ||
519 | return val; | ||
520 | } | 509 | } |
521 | 510 | ||
522 | static void mostek_write_byte(struct device *dev, u32 ofs, u8 val) | 511 | static void mostek_write_byte(struct device *dev, u32 ofs, u8 val) |
523 | { | 512 | { |
524 | struct platform_device *pdev = to_platform_device(dev); | 513 | struct platform_device *pdev = to_platform_device(dev); |
525 | struct m48t59_plat_data *pdata = pdev->dev.platform_data; | 514 | void __iomem *regs = (void __iomem *) pdev->resource[0].start; |
526 | void __iomem *regs; | 515 | |
527 | |||
528 | regs = (void __iomem *) pdev->resource[0].start; | ||
529 | if (ofs == pdata->offset + M48T59_YEAR) { | ||
530 | if (val < 0x68) | ||
531 | val += 0x32; | ||
532 | else | ||
533 | val -= 0x68; | ||
534 | if ((val & 0xf) > 9) | ||
535 | val += 6; | ||
536 | if ((val & 0xf0) > 0x9A) | ||
537 | val += 0x60; | ||
538 | } | ||
539 | writeb(val, regs + ofs); | 516 | writeb(val, regs + ofs); |
540 | } | 517 | } |
541 | 518 | ||