Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 2 | // |
| 3 | // Copyright (C) 2018 ROHM Semiconductors |
| 4 | // |
Matti Vaittinen | e5e3352 | 2021-05-27 13:58:19 +0300 | [diff] [blame] | 5 | // RTC driver for ROHM BD71828 and BD71815 PMIC |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 6 | |
| 7 | #include <linux/bcd.h> |
Matti Vaittinen | c56dc06 | 2021-04-05 14:44:50 +0300 | [diff] [blame] | 8 | #include <linux/mfd/rohm-bd71815.h> |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 9 | #include <linux/mfd/rohm-bd71828.h> |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 10 | #include <linux/module.h> |
| 11 | #include <linux/of.h> |
| 12 | #include <linux/platform_device.h> |
| 13 | #include <linux/regmap.h> |
| 14 | #include <linux/rtc.h> |
| 15 | |
| 16 | /* |
Matti Vaittinen | c56dc06 | 2021-04-05 14:44:50 +0300 | [diff] [blame] | 17 | * On BD71828 and BD71815 the ALM0 MASK is 14 bytes after the ALM0 |
| 18 | * block start |
| 19 | */ |
| 20 | #define BD718XX_ALM_EN_OFFSET 14 |
| 21 | |
| 22 | /* |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 23 | * We read regs RTC_SEC => RTC_YEAR |
| 24 | * this struct is ordered according to chip registers. |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 25 | * Keep it u8 only (or packed) to avoid padding issues. |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 26 | */ |
| 27 | struct bd70528_rtc_day { |
| 28 | u8 sec; |
| 29 | u8 min; |
| 30 | u8 hour; |
| 31 | } __packed; |
| 32 | |
| 33 | struct bd70528_rtc_data { |
| 34 | struct bd70528_rtc_day time; |
| 35 | u8 week; |
| 36 | u8 day; |
| 37 | u8 month; |
| 38 | u8 year; |
| 39 | } __packed; |
| 40 | |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 41 | struct bd71828_rtc_alm { |
| 42 | struct bd70528_rtc_data alm0; |
| 43 | struct bd70528_rtc_data alm1; |
| 44 | u8 alm_mask; |
| 45 | u8 alm1_mask; |
| 46 | } __packed; |
| 47 | |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 48 | struct bd70528_rtc { |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 49 | struct rohm_regmap_dev *parent; |
Matti Vaittinen | f87c0d2 | 2021-04-05 14:40:24 +0300 | [diff] [blame] | 50 | struct regmap *regmap; |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 51 | struct device *dev; |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 52 | u8 reg_time_start; |
Matti Vaittinen | c56dc06 | 2021-04-05 14:44:50 +0300 | [diff] [blame] | 53 | u8 bd718xx_alm_block_start; |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 54 | }; |
| 55 | |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 56 | static inline void tmday2rtc(struct rtc_time *t, struct bd70528_rtc_day *d) |
| 57 | { |
| 58 | d->sec &= ~BD70528_MASK_RTC_SEC; |
| 59 | d->min &= ~BD70528_MASK_RTC_MINUTE; |
| 60 | d->hour &= ~BD70528_MASK_RTC_HOUR; |
| 61 | d->sec |= bin2bcd(t->tm_sec); |
| 62 | d->min |= bin2bcd(t->tm_min); |
| 63 | d->hour |= bin2bcd(t->tm_hour); |
| 64 | } |
| 65 | |
| 66 | static inline void tm2rtc(struct rtc_time *t, struct bd70528_rtc_data *r) |
| 67 | { |
| 68 | r->day &= ~BD70528_MASK_RTC_DAY; |
| 69 | r->week &= ~BD70528_MASK_RTC_WEEK; |
| 70 | r->month &= ~BD70528_MASK_RTC_MONTH; |
| 71 | /* |
| 72 | * PM and 24H bits are not used by Wake - thus we clear them |
| 73 | * here and not in tmday2rtc() which is also used by wake. |
| 74 | */ |
| 75 | r->time.hour &= ~(BD70528_MASK_RTC_HOUR_PM | BD70528_MASK_RTC_HOUR_24H); |
| 76 | |
| 77 | tmday2rtc(t, &r->time); |
| 78 | /* |
| 79 | * We do always set time in 24H mode. |
| 80 | */ |
| 81 | r->time.hour |= BD70528_MASK_RTC_HOUR_24H; |
| 82 | r->day |= bin2bcd(t->tm_mday); |
| 83 | r->week |= bin2bcd(t->tm_wday); |
| 84 | r->month |= bin2bcd(t->tm_mon + 1); |
| 85 | r->year = bin2bcd(t->tm_year - 100); |
| 86 | } |
| 87 | |
| 88 | static inline void rtc2tm(struct bd70528_rtc_data *r, struct rtc_time *t) |
| 89 | { |
| 90 | t->tm_sec = bcd2bin(r->time.sec & BD70528_MASK_RTC_SEC); |
| 91 | t->tm_min = bcd2bin(r->time.min & BD70528_MASK_RTC_MINUTE); |
| 92 | t->tm_hour = bcd2bin(r->time.hour & BD70528_MASK_RTC_HOUR); |
| 93 | /* |
| 94 | * If RTC is in 12H mode, then bit BD70528_MASK_RTC_HOUR_PM |
| 95 | * is not BCD value but tells whether it is AM or PM |
| 96 | */ |
| 97 | if (!(r->time.hour & BD70528_MASK_RTC_HOUR_24H)) { |
| 98 | t->tm_hour %= 12; |
| 99 | if (r->time.hour & BD70528_MASK_RTC_HOUR_PM) |
| 100 | t->tm_hour += 12; |
| 101 | } |
| 102 | t->tm_mday = bcd2bin(r->day & BD70528_MASK_RTC_DAY); |
| 103 | t->tm_mon = bcd2bin(r->month & BD70528_MASK_RTC_MONTH) - 1; |
| 104 | t->tm_year = 100 + bcd2bin(r->year & BD70528_MASK_RTC_YEAR); |
| 105 | t->tm_wday = bcd2bin(r->week & BD70528_MASK_RTC_WEEK); |
| 106 | } |
| 107 | |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 108 | static int bd71828_set_alarm(struct device *dev, struct rtc_wkalrm *a) |
| 109 | { |
| 110 | int ret; |
| 111 | struct bd71828_rtc_alm alm; |
| 112 | struct bd70528_rtc *r = dev_get_drvdata(dev); |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 113 | |
Matti Vaittinen | c56dc06 | 2021-04-05 14:44:50 +0300 | [diff] [blame] | 114 | ret = regmap_bulk_read(r->regmap, r->bd718xx_alm_block_start, &alm, |
| 115 | sizeof(alm)); |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 116 | if (ret) { |
| 117 | dev_err(dev, "Failed to read alarm regs\n"); |
| 118 | return ret; |
| 119 | } |
| 120 | |
| 121 | tm2rtc(&a->time, &alm.alm0); |
| 122 | |
| 123 | if (!a->enabled) |
| 124 | alm.alm_mask &= ~BD70528_MASK_ALM_EN; |
| 125 | else |
| 126 | alm.alm_mask |= BD70528_MASK_ALM_EN; |
| 127 | |
Matti Vaittinen | c56dc06 | 2021-04-05 14:44:50 +0300 | [diff] [blame] | 128 | ret = regmap_bulk_write(r->regmap, r->bd718xx_alm_block_start, &alm, |
| 129 | sizeof(alm)); |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 130 | if (ret) |
| 131 | dev_err(dev, "Failed to set alarm time\n"); |
| 132 | |
| 133 | return ret; |
| 134 | |
| 135 | } |
| 136 | |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 137 | static int bd71828_read_alarm(struct device *dev, struct rtc_wkalrm *a) |
| 138 | { |
| 139 | int ret; |
| 140 | struct bd71828_rtc_alm alm; |
| 141 | struct bd70528_rtc *r = dev_get_drvdata(dev); |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 142 | |
Matti Vaittinen | c56dc06 | 2021-04-05 14:44:50 +0300 | [diff] [blame] | 143 | ret = regmap_bulk_read(r->regmap, r->bd718xx_alm_block_start, &alm, |
| 144 | sizeof(alm)); |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 145 | if (ret) { |
| 146 | dev_err(dev, "Failed to read alarm regs\n"); |
| 147 | return ret; |
| 148 | } |
| 149 | |
| 150 | rtc2tm(&alm.alm0, &a->time); |
| 151 | a->time.tm_mday = -1; |
| 152 | a->time.tm_mon = -1; |
| 153 | a->time.tm_year = -1; |
| 154 | a->enabled = !!(alm.alm_mask & BD70528_MASK_ALM_EN); |
| 155 | a->pending = 0; |
| 156 | |
| 157 | return 0; |
| 158 | } |
| 159 | |
Matti Vaittinen | e5e3352 | 2021-05-27 13:58:19 +0300 | [diff] [blame] | 160 | static int bd71828_set_time(struct device *dev, struct rtc_time *t) |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 161 | { |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 162 | int ret; |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 163 | struct bd70528_rtc_data rtc_data; |
| 164 | struct bd70528_rtc *r = dev_get_drvdata(dev); |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 165 | |
Matti Vaittinen | e5e3352 | 2021-05-27 13:58:19 +0300 | [diff] [blame] | 166 | ret = regmap_bulk_read(r->regmap, r->reg_time_start, &rtc_data, |
| 167 | sizeof(rtc_data)); |
| 168 | if (ret) { |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 169 | dev_err(dev, "Failed to read RTC time registers\n"); |
Matti Vaittinen | e5e3352 | 2021-05-27 13:58:19 +0300 | [diff] [blame] | 170 | return ret; |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 171 | } |
| 172 | tm2rtc(t, &rtc_data); |
| 173 | |
Matti Vaittinen | e5e3352 | 2021-05-27 13:58:19 +0300 | [diff] [blame] | 174 | ret = regmap_bulk_write(r->regmap, r->reg_time_start, &rtc_data, |
| 175 | sizeof(rtc_data)); |
| 176 | if (ret) |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 177 | dev_err(dev, "Failed to set RTC time\n"); |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 178 | |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 179 | return ret; |
| 180 | } |
| 181 | |
| 182 | static int bd70528_get_time(struct device *dev, struct rtc_time *t) |
| 183 | { |
| 184 | struct bd70528_rtc *r = dev_get_drvdata(dev); |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 185 | struct bd70528_rtc_data rtc_data; |
| 186 | int ret; |
| 187 | |
| 188 | /* read the RTC date and time registers all at once */ |
Matti Vaittinen | f87c0d2 | 2021-04-05 14:40:24 +0300 | [diff] [blame] | 189 | ret = regmap_bulk_read(r->regmap, r->reg_time_start, &rtc_data, |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 190 | sizeof(rtc_data)); |
| 191 | if (ret) { |
| 192 | dev_err(dev, "Failed to read RTC time (err %d)\n", ret); |
| 193 | return ret; |
| 194 | } |
| 195 | |
| 196 | rtc2tm(&rtc_data, t); |
| 197 | |
| 198 | return 0; |
| 199 | } |
| 200 | |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 201 | static int bd71828_alm_enable(struct device *dev, unsigned int enabled) |
| 202 | { |
| 203 | int ret; |
| 204 | struct bd70528_rtc *r = dev_get_drvdata(dev); |
| 205 | unsigned int enableval = BD70528_MASK_ALM_EN; |
| 206 | |
| 207 | if (!enabled) |
| 208 | enableval = 0; |
| 209 | |
Matti Vaittinen | c56dc06 | 2021-04-05 14:44:50 +0300 | [diff] [blame] | 210 | ret = regmap_update_bits(r->regmap, r->bd718xx_alm_block_start + |
| 211 | BD718XX_ALM_EN_OFFSET, BD70528_MASK_ALM_EN, |
| 212 | enableval); |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 213 | if (ret) |
| 214 | dev_err(dev, "Failed to change alarm state\n"); |
| 215 | |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 216 | return ret; |
| 217 | } |
| 218 | |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 219 | static const struct rtc_class_ops bd71828_rtc_ops = { |
| 220 | .read_time = bd70528_get_time, |
| 221 | .set_time = bd71828_set_time, |
| 222 | .read_alarm = bd71828_read_alarm, |
| 223 | .set_alarm = bd71828_set_alarm, |
| 224 | .alarm_irq_enable = bd71828_alm_enable, |
| 225 | }; |
| 226 | |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 227 | static irqreturn_t alm_hndlr(int irq, void *data) |
| 228 | { |
| 229 | struct rtc_device *rtc = data; |
| 230 | |
| 231 | rtc_update_irq(rtc, 1, RTC_IRQF | RTC_AF | RTC_PF); |
| 232 | return IRQ_HANDLED; |
| 233 | } |
| 234 | |
| 235 | static int bd70528_probe(struct platform_device *pdev) |
| 236 | { |
| 237 | struct bd70528_rtc *bd_rtc; |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 238 | const struct rtc_class_ops *rtc_ops; |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 239 | const char *irq_name; |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 240 | int ret; |
| 241 | struct rtc_device *rtc; |
| 242 | int irq; |
| 243 | unsigned int hr; |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 244 | u8 hour_reg; |
| 245 | enum rohm_chip_type chip = platform_get_device_id(pdev)->driver_data; |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 246 | |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 247 | bd_rtc = devm_kzalloc(&pdev->dev, sizeof(*bd_rtc), GFP_KERNEL); |
| 248 | if (!bd_rtc) |
| 249 | return -ENOMEM; |
| 250 | |
Matti Vaittinen | f87c0d2 | 2021-04-05 14:40:24 +0300 | [diff] [blame] | 251 | bd_rtc->regmap = dev_get_regmap(pdev->dev.parent, NULL); |
| 252 | if (!bd_rtc->regmap) { |
| 253 | dev_err(&pdev->dev, "No regmap\n"); |
| 254 | return -EINVAL; |
| 255 | } |
| 256 | |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 257 | bd_rtc->dev = &pdev->dev; |
Matti Vaittinen | e5e3352 | 2021-05-27 13:58:19 +0300 | [diff] [blame] | 258 | rtc_ops = &bd71828_rtc_ops; |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 259 | |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 260 | switch (chip) { |
Matti Vaittinen | c56dc06 | 2021-04-05 14:44:50 +0300 | [diff] [blame] | 261 | case ROHM_CHIP_TYPE_BD71815: |
| 262 | irq_name = "bd71815-rtc-alm-0"; |
| 263 | bd_rtc->reg_time_start = BD71815_REG_RTC_START; |
| 264 | |
| 265 | /* |
| 266 | * See also BD718XX_ALM_EN_OFFSET: |
| 267 | * This works for BD71828 and BD71815 as they have same offset |
| 268 | * between ALM0 start and ALM0_MASK. If new ICs are to be |
| 269 | * added this requires proper check as ALM0_MASK is not located |
| 270 | * at the end of ALM0 block - but after all ALM blocks so if |
| 271 | * amount of ALMs differ the offset to enable/disable is likely |
| 272 | * to be incorrect and enable/disable must be given as own |
| 273 | * reg address here. |
| 274 | */ |
| 275 | bd_rtc->bd718xx_alm_block_start = BD71815_REG_RTC_ALM_START; |
| 276 | hour_reg = BD71815_REG_HOUR; |
Matti Vaittinen | c56dc06 | 2021-04-05 14:44:50 +0300 | [diff] [blame] | 277 | break; |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 278 | case ROHM_CHIP_TYPE_BD71828: |
| 279 | irq_name = "bd71828-rtc-alm-0"; |
| 280 | bd_rtc->reg_time_start = BD71828_REG_RTC_START; |
Matti Vaittinen | c56dc06 | 2021-04-05 14:44:50 +0300 | [diff] [blame] | 281 | bd_rtc->bd718xx_alm_block_start = BD71828_REG_RTC_ALM_START; |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 282 | hour_reg = BD71828_REG_RTC_HOUR; |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 283 | break; |
| 284 | default: |
| 285 | dev_err(&pdev->dev, "Unknown chip\n"); |
| 286 | return -ENOENT; |
| 287 | } |
| 288 | |
| 289 | irq = platform_get_irq_byname(pdev, irq_name); |
| 290 | |
Keyur Patel | 6e7af45 | 2020-03-21 14:08:37 -0400 | [diff] [blame] | 291 | if (irq < 0) |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 292 | return irq; |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 293 | |
| 294 | platform_set_drvdata(pdev, bd_rtc); |
| 295 | |
Matti Vaittinen | f87c0d2 | 2021-04-05 14:40:24 +0300 | [diff] [blame] | 296 | ret = regmap_read(bd_rtc->regmap, hour_reg, &hr); |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 297 | |
| 298 | if (ret) { |
| 299 | dev_err(&pdev->dev, "Failed to reag RTC clock\n"); |
| 300 | return ret; |
| 301 | } |
| 302 | |
| 303 | if (!(hr & BD70528_MASK_RTC_HOUR_24H)) { |
| 304 | struct rtc_time t; |
| 305 | |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 306 | ret = rtc_ops->read_time(&pdev->dev, &t); |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 307 | |
| 308 | if (!ret) |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 309 | ret = rtc_ops->set_time(&pdev->dev, &t); |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 310 | |
| 311 | if (ret) { |
| 312 | dev_err(&pdev->dev, |
| 313 | "Setting 24H clock for RTC failed\n"); |
| 314 | return ret; |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | device_set_wakeup_capable(&pdev->dev, true); |
| 319 | device_wakeup_enable(&pdev->dev); |
| 320 | |
| 321 | rtc = devm_rtc_allocate_device(&pdev->dev); |
| 322 | if (IS_ERR(rtc)) { |
| 323 | dev_err(&pdev->dev, "RTC device creation failed\n"); |
| 324 | return PTR_ERR(rtc); |
| 325 | } |
| 326 | |
| 327 | rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; |
| 328 | rtc->range_max = RTC_TIMESTAMP_END_2099; |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 329 | rtc->ops = rtc_ops; |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 330 | |
| 331 | /* Request alarm IRQ prior to registerig the RTC */ |
| 332 | ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, &alm_hndlr, |
| 333 | IRQF_ONESHOT, "bd70528-rtc", rtc); |
| 334 | if (ret) |
| 335 | return ret; |
| 336 | |
Bartosz Golaszewski | fdcfd85 | 2020-11-09 17:34:08 +0100 | [diff] [blame] | 337 | return devm_rtc_register_device(rtc); |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 338 | } |
| 339 | |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 340 | static const struct platform_device_id bd718x7_rtc_id[] = { |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 341 | { "bd71828-rtc", ROHM_CHIP_TYPE_BD71828 }, |
Matti Vaittinen | c56dc06 | 2021-04-05 14:44:50 +0300 | [diff] [blame] | 342 | { "bd71815-rtc", ROHM_CHIP_TYPE_BD71815 }, |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 343 | { }, |
| 344 | }; |
| 345 | MODULE_DEVICE_TABLE(platform, bd718x7_rtc_id); |
| 346 | |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 347 | static struct platform_driver bd70528_rtc = { |
| 348 | .driver = { |
| 349 | .name = "bd70528-rtc" |
| 350 | }, |
| 351 | .probe = bd70528_probe, |
Matti Vaittinen | fe5a591 | 2020-01-20 15:45:36 +0200 | [diff] [blame] | 352 | .id_table = bd718x7_rtc_id, |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 353 | }; |
| 354 | |
| 355 | module_platform_driver(bd70528_rtc); |
| 356 | |
| 357 | MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>"); |
Matti Vaittinen | e5e3352 | 2021-05-27 13:58:19 +0300 | [diff] [blame] | 358 | MODULE_DESCRIPTION("ROHM BD71828 and BD71815 PMIC RTC driver"); |
Matti Vaittinen | 32a4a4e | 2019-06-03 10:27:14 +0300 | [diff] [blame] | 359 | MODULE_LICENSE("GPL"); |
Colin Ian King | afe19a7 | 2019-11-06 08:34:18 +0000 | [diff] [blame] | 360 | MODULE_ALIAS("platform:bd70528-rtc"); |