Lines Matching +full:- +full:p1

1 // SPDX-License-Identifier: GPL-2.0
3 * Driver for the RTC found in the SpacemiT P1 PMIC
15 #define MOD_NAME "spacemit-p1-rtc"
18 * Six consecutive 1-byte registers hold the seconds, minutes, hours,
19 * day-of-month, month, and year (respectively).
22 * seconds 0-59
23 * minutes 0-59
24 * hours 0-59
25 * day 0-30 (struct tm is 1-31)
26 * month 0-11
46 * The P1 hardware documentation states that the register values are
53 struct p1_rtc *p1 = dev_get_drvdata(dev); in p1_rtc_read_time() local
54 struct regmap *regmap = p1->regmap; in p1_rtc_read_time()
61 return -EINVAL; /* RTC is disabled */ in p1_rtc_read_time()
72 } while (time[0] != seconds && --count); in p1_rtc_read_time()
75 return -EIO; /* Unable to get a consistent result */ in p1_rtc_read_time()
77 t->tm_sec = time[0] & GENMASK(5, 0); in p1_rtc_read_time()
78 t->tm_min = time[1] & GENMASK(5, 0); in p1_rtc_read_time()
79 t->tm_hour = time[2] & GENMASK(4, 0); in p1_rtc_read_time()
80 t->tm_mday = (time[3] & GENMASK(4, 0)) + 1; in p1_rtc_read_time()
81 t->tm_mon = time[4] & GENMASK(3, 0); in p1_rtc_read_time()
82 t->tm_year = (time[5] & GENMASK(5, 0)) + 100; in p1_rtc_read_time()
88 * The P1 hardware documentation states that values in the registers are
95 struct p1_rtc *p1 = dev_get_drvdata(dev); in p1_rtc_set_time() local
96 struct regmap *regmap = p1->regmap; in p1_rtc_set_time()
100 time[0] = t->tm_sec; in p1_rtc_set_time()
101 time[1] = t->tm_min; in p1_rtc_set_time()
102 time[2] = t->tm_hour; in p1_rtc_set_time()
103 time[3] = t->tm_mday - 1; in p1_rtc_set_time()
104 time[4] = t->tm_mon; in p1_rtc_set_time()
105 time[5] = t->tm_year - 100; in p1_rtc_set_time()
107 /* Disable the RTC to update; re-enable again when done */ in p1_rtc_set_time()
127 struct device *dev = &pdev->dev; in p1_rtc_probe()
129 struct p1_rtc *p1; in p1_rtc_probe() local
131 p1 = devm_kzalloc(dev, sizeof(*p1), GFP_KERNEL); in p1_rtc_probe()
132 if (!p1) in p1_rtc_probe()
133 return -ENOMEM; in p1_rtc_probe()
134 dev_set_drvdata(dev, p1); in p1_rtc_probe()
136 p1->regmap = dev_get_regmap(dev->parent, NULL); in p1_rtc_probe()
137 if (!p1->regmap) in p1_rtc_probe()
138 return dev_err_probe(dev, -ENODEV, "failed to get regmap\n"); in p1_rtc_probe()
144 p1->rtc = rtc; in p1_rtc_probe()
146 rtc->ops = &p1_rtc_class_ops; in p1_rtc_probe()
147 rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; in p1_rtc_probe()
148 rtc->range_max = RTC_TIMESTAMP_END_2063; in p1_rtc_probe()
150 clear_bit(RTC_FEATURE_ALARM, rtc->features); in p1_rtc_probe()
151 clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rtc->features); in p1_rtc_probe()
165 MODULE_DESCRIPTION("SpacemiT P1 RTC driver");