aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/chips/menelaus.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/chips/menelaus.c')
-rw-r--r--drivers/i2c/chips/menelaus.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/drivers/i2c/chips/menelaus.c b/drivers/i2c/chips/menelaus.c
index b36db1797c11..4b364bae6b3e 100644
--- a/drivers/i2c/chips/menelaus.c
+++ b/drivers/i2c/chips/menelaus.c
@@ -41,11 +41,10 @@
41#include <linux/rtc.h> 41#include <linux/rtc.h>
42#include <linux/bcd.h> 42#include <linux/bcd.h>
43 43
44#include <asm/mach-types.h>
45#include <asm/mach/irq.h> 44#include <asm/mach/irq.h>
46 45
47#include <asm/arch/gpio.h> 46#include <mach/gpio.h>
48#include <asm/arch/menelaus.h> 47#include <mach/menelaus.h>
49 48
50#define DRIVER_NAME "menelaus" 49#define DRIVER_NAME "menelaus"
51 50
@@ -833,52 +832,52 @@ static irqreturn_t menelaus_irq(int irq, void *_menelaus)
833 832
834static void menelaus_to_time(char *regs, struct rtc_time *t) 833static void menelaus_to_time(char *regs, struct rtc_time *t)
835{ 834{
836 t->tm_sec = BCD2BIN(regs[0]); 835 t->tm_sec = bcd2bin(regs[0]);
837 t->tm_min = BCD2BIN(regs[1]); 836 t->tm_min = bcd2bin(regs[1]);
838 if (the_menelaus->rtc_control & RTC_CTRL_MODE12) { 837 if (the_menelaus->rtc_control & RTC_CTRL_MODE12) {
839 t->tm_hour = BCD2BIN(regs[2] & 0x1f) - 1; 838 t->tm_hour = bcd2bin(regs[2] & 0x1f) - 1;
840 if (regs[2] & RTC_HR_PM) 839 if (regs[2] & RTC_HR_PM)
841 t->tm_hour += 12; 840 t->tm_hour += 12;
842 } else 841 } else
843 t->tm_hour = BCD2BIN(regs[2] & 0x3f); 842 t->tm_hour = bcd2bin(regs[2] & 0x3f);
844 t->tm_mday = BCD2BIN(regs[3]); 843 t->tm_mday = bcd2bin(regs[3]);
845 t->tm_mon = BCD2BIN(regs[4]) - 1; 844 t->tm_mon = bcd2bin(regs[4]) - 1;
846 t->tm_year = BCD2BIN(regs[5]) + 100; 845 t->tm_year = bcd2bin(regs[5]) + 100;
847} 846}
848 847
849static int time_to_menelaus(struct rtc_time *t, int regnum) 848static int time_to_menelaus(struct rtc_time *t, int regnum)
850{ 849{
851 int hour, status; 850 int hour, status;
852 851
853 status = menelaus_write_reg(regnum++, BIN2BCD(t->tm_sec)); 852 status = menelaus_write_reg(regnum++, bin2bcd(t->tm_sec));
854 if (status < 0) 853 if (status < 0)
855 goto fail; 854 goto fail;
856 855
857 status = menelaus_write_reg(regnum++, BIN2BCD(t->tm_min)); 856 status = menelaus_write_reg(regnum++, bin2bcd(t->tm_min));
858 if (status < 0) 857 if (status < 0)
859 goto fail; 858 goto fail;
860 859
861 if (the_menelaus->rtc_control & RTC_CTRL_MODE12) { 860 if (the_menelaus->rtc_control & RTC_CTRL_MODE12) {
862 hour = t->tm_hour + 1; 861 hour = t->tm_hour + 1;
863 if (hour > 12) 862 if (hour > 12)
864 hour = RTC_HR_PM | BIN2BCD(hour - 12); 863 hour = RTC_HR_PM | bin2bcd(hour - 12);
865 else 864 else
866 hour = BIN2BCD(hour); 865 hour = bin2bcd(hour);
867 } else 866 } else
868 hour = BIN2BCD(t->tm_hour); 867 hour = bin2bcd(t->tm_hour);
869 status = menelaus_write_reg(regnum++, hour); 868 status = menelaus_write_reg(regnum++, hour);
870 if (status < 0) 869 if (status < 0)
871 goto fail; 870 goto fail;
872 871
873 status = menelaus_write_reg(regnum++, BIN2BCD(t->tm_mday)); 872 status = menelaus_write_reg(regnum++, bin2bcd(t->tm_mday));
874 if (status < 0) 873 if (status < 0)
875 goto fail; 874 goto fail;
876 875
877 status = menelaus_write_reg(regnum++, BIN2BCD(t->tm_mon + 1)); 876 status = menelaus_write_reg(regnum++, bin2bcd(t->tm_mon + 1));
878 if (status < 0) 877 if (status < 0)
879 goto fail; 878 goto fail;
880 879
881 status = menelaus_write_reg(regnum++, BIN2BCD(t->tm_year - 100)); 880 status = menelaus_write_reg(regnum++, bin2bcd(t->tm_year - 100));
882 if (status < 0) 881 if (status < 0)
883 goto fail; 882 goto fail;
884 883
@@ -915,7 +914,7 @@ static int menelaus_read_time(struct device *dev, struct rtc_time *t)
915 } 914 }
916 915
917 menelaus_to_time(regs, t); 916 menelaus_to_time(regs, t);
918 t->tm_wday = BCD2BIN(regs[6]); 917 t->tm_wday = bcd2bin(regs[6]);
919 918
920 return 0; 919 return 0;
921} 920}
@@ -928,7 +927,7 @@ static int menelaus_set_time(struct device *dev, struct rtc_time *t)
928 status = time_to_menelaus(t, MENELAUS_RTC_SEC); 927 status = time_to_menelaus(t, MENELAUS_RTC_SEC);
929 if (status < 0) 928 if (status < 0)
930 return status; 929 return status;
931 status = menelaus_write_reg(MENELAUS_RTC_WKDAY, BIN2BCD(t->tm_wday)); 930 status = menelaus_write_reg(MENELAUS_RTC_WKDAY, bin2bcd(t->tm_wday));
932 if (status < 0) { 931 if (status < 0) {
933 dev_err(&the_menelaus->client->dev, "rtc write reg %02x " 932 dev_err(&the_menelaus->client->dev, "rtc write reg %02x "
934 "err %d\n", MENELAUS_RTC_WKDAY, status); 933 "err %d\n", MENELAUS_RTC_WKDAY, status);