Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtc: bd70528: Drop BD70528 support

The only known BD70528 use-cases are such that the PMIC is controlled
from separate MCU which is not running Linux. I am not aware of
any Linux driver users. Furthermore, it seems there is no demand for
this IC. Let's ease the maintenance burden and drop the driver. We can
always add it back if there is sudden need for it.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/20210527105819.GA3111334@localhost.localdomain

authored by

Matti Vaittinen and committed by
Alexandre Belloni
e5e33525 742b0d7e

+14 -309
+3 -4
drivers/rtc/Kconfig
··· 501 501 watchdog timer in the ST M41T60 and M41T80 RTC chips series. 502 502 503 503 config RTC_DRV_BD70528 504 - tristate "ROHM BD70528, BD71815 and BD71828 PMIC RTC" 505 - depends on MFD_ROHM_BD71828 || MFD_ROHM_BD70528 506 - depends on BD70528_WATCHDOG || !BD70528_WATCHDOG 504 + tristate "ROHM BD71815 and BD71828 PMIC RTC" 505 + depends on MFD_ROHM_BD71828 507 506 help 508 507 If you say Y here you will get support for the RTC 509 - block on ROHM BD70528, BD71815 and BD71828 Power Management IC. 508 + block on ROHM BD71815 and BD71828 Power Management IC. 510 509 511 510 This driver can also be built as a module. If so, the module 512 511 will be called rtc-bd70528.
+11 -305
drivers/rtc/rtc-bd70528.c
··· 2 2 // 3 3 // Copyright (C) 2018 ROHM Semiconductors 4 4 // 5 - // RTC driver for ROHM BD70528 PMIC 5 + // RTC driver for ROHM BD71828 and BD71815 PMIC 6 6 7 7 #include <linux/bcd.h> 8 - #include <linux/mfd/rohm-bd70528.h> 9 8 #include <linux/mfd/rohm-bd71815.h> 10 9 #include <linux/mfd/rohm-bd71828.h> 11 10 #include <linux/module.h> ··· 38 39 u8 year; 39 40 } __packed; 40 41 41 - struct bd70528_rtc_wake { 42 - struct bd70528_rtc_day time; 43 - u8 ctrl; 44 - } __packed; 45 - 46 42 struct bd71828_rtc_alm { 47 43 struct bd70528_rtc_data alm0; 48 44 struct bd70528_rtc_data alm1; 49 45 u8 alm_mask; 50 46 u8 alm1_mask; 51 - } __packed; 52 - 53 - struct bd70528_rtc_alm { 54 - struct bd70528_rtc_data data; 55 - u8 alm_mask; 56 - u8 alm_repeat; 57 47 } __packed; 58 48 59 49 struct bd70528_rtc { ··· 51 63 struct device *dev; 52 64 u8 reg_time_start; 53 65 u8 bd718xx_alm_block_start; 54 - bool has_rtc_timers; 55 66 }; 56 - 57 - static int bd70528_set_wake(struct rohm_regmap_dev *bd70528, 58 - int enable, int *old_state) 59 - { 60 - int ret; 61 - unsigned int ctrl_reg; 62 - 63 - ret = regmap_read(bd70528->regmap, BD70528_REG_WAKE_EN, &ctrl_reg); 64 - if (ret) 65 - return ret; 66 - 67 - if (old_state) { 68 - if (ctrl_reg & BD70528_MASK_WAKE_EN) 69 - *old_state |= BD70528_WAKE_STATE_BIT; 70 - else 71 - *old_state &= ~BD70528_WAKE_STATE_BIT; 72 - 73 - if (!enable == !(*old_state & BD70528_WAKE_STATE_BIT)) 74 - return 0; 75 - } 76 - 77 - if (enable) 78 - ctrl_reg |= BD70528_MASK_WAKE_EN; 79 - else 80 - ctrl_reg &= ~BD70528_MASK_WAKE_EN; 81 - 82 - return regmap_write(bd70528->regmap, BD70528_REG_WAKE_EN, 83 - ctrl_reg); 84 - } 85 - 86 - static int bd70528_set_elapsed_tmr(struct rohm_regmap_dev *bd70528, 87 - int enable, int *old_state) 88 - { 89 - int ret; 90 - unsigned int ctrl_reg; 91 - 92 - /* 93 - * TBD 94 - * What is the purpose of elapsed timer ? 95 - * Is the timeout registers counting down, or is the disable - re-enable 96 - * going to restart the elapsed-time counting? If counting is restarted 97 - * the timeout should be decreased by the amount of time that has 98 - * elapsed since starting the timer. Maybe we should store the monotonic 99 - * clock value when timer is started so that if RTC is set while timer 100 - * is armed we could do the compensation. This is a hack if RTC/system 101 - * clk are drifting. OTOH, RTC controlled via I2C is in any case 102 - * inaccurate... 103 - */ 104 - ret = regmap_read(bd70528->regmap, BD70528_REG_ELAPSED_TIMER_EN, 105 - &ctrl_reg); 106 - if (ret) 107 - return ret; 108 - 109 - if (old_state) { 110 - if (ctrl_reg & BD70528_MASK_ELAPSED_TIMER_EN) 111 - *old_state |= BD70528_ELAPSED_STATE_BIT; 112 - else 113 - *old_state &= ~BD70528_ELAPSED_STATE_BIT; 114 - 115 - if ((!enable) == (!(*old_state & BD70528_ELAPSED_STATE_BIT))) 116 - return 0; 117 - } 118 - 119 - if (enable) 120 - ctrl_reg |= BD70528_MASK_ELAPSED_TIMER_EN; 121 - else 122 - ctrl_reg &= ~BD70528_MASK_ELAPSED_TIMER_EN; 123 - 124 - return regmap_write(bd70528->regmap, BD70528_REG_ELAPSED_TIMER_EN, 125 - ctrl_reg); 126 - } 127 - 128 - static int bd70528_set_rtc_based_timers(struct bd70528_rtc *r, int new_state, 129 - int *old_state) 130 - { 131 - int ret; 132 - 133 - ret = bd70528_wdt_set(r->parent, new_state & BD70528_WDT_STATE_BIT, 134 - old_state); 135 - if (ret) { 136 - dev_err(r->dev, 137 - "Failed to disable WDG for RTC setting (%d)\n", ret); 138 - return ret; 139 - } 140 - ret = bd70528_set_elapsed_tmr(r->parent, 141 - new_state & BD70528_ELAPSED_STATE_BIT, 142 - old_state); 143 - if (ret) { 144 - dev_err(r->dev, 145 - "Failed to disable 'elapsed timer' for RTC setting\n"); 146 - return ret; 147 - } 148 - ret = bd70528_set_wake(r->parent, new_state & BD70528_WAKE_STATE_BIT, 149 - old_state); 150 - if (ret) { 151 - dev_err(r->dev, 152 - "Failed to disable 'wake timer' for RTC setting\n"); 153 - return ret; 154 - } 155 - 156 - return ret; 157 - } 158 - 159 - static int bd70528_re_enable_rtc_based_timers(struct bd70528_rtc *r, 160 - int old_state) 161 - { 162 - if (!r->has_rtc_timers) 163 - return 0; 164 - 165 - return bd70528_set_rtc_based_timers(r, old_state, NULL); 166 - } 167 - 168 - static int bd70528_disable_rtc_based_timers(struct bd70528_rtc *r, 169 - int *old_state) 170 - { 171 - if (!r->has_rtc_timers) 172 - return 0; 173 - 174 - return bd70528_set_rtc_based_timers(r, 0, old_state); 175 - } 176 67 177 68 static inline void tmday2rtc(struct rtc_time *t, struct bd70528_rtc_day *d) 178 69 { ··· 134 267 135 268 } 136 269 137 - static int bd70528_set_alarm(struct device *dev, struct rtc_wkalrm *a) 138 - { 139 - struct bd70528_rtc_wake wake; 140 - struct bd70528_rtc_alm alm; 141 - int ret; 142 - struct bd70528_rtc *r = dev_get_drvdata(dev); 143 - 144 - ret = regmap_bulk_read(r->regmap, BD70528_REG_RTC_WAKE_START, &wake, 145 - sizeof(wake)); 146 - if (ret) { 147 - dev_err(dev, "Failed to read wake regs\n"); 148 - return ret; 149 - } 150 - 151 - ret = regmap_bulk_read(r->regmap, BD70528_REG_RTC_ALM_START, &alm, 152 - sizeof(alm)); 153 - if (ret) { 154 - dev_err(dev, "Failed to read alarm regs\n"); 155 - return ret; 156 - } 157 - 158 - tm2rtc(&a->time, &alm.data); 159 - tmday2rtc(&a->time, &wake.time); 160 - 161 - if (a->enabled) { 162 - alm.alm_mask &= ~BD70528_MASK_ALM_EN; 163 - wake.ctrl |= BD70528_MASK_WAKE_EN; 164 - } else { 165 - alm.alm_mask |= BD70528_MASK_ALM_EN; 166 - wake.ctrl &= ~BD70528_MASK_WAKE_EN; 167 - } 168 - 169 - ret = regmap_bulk_write(r->regmap, BD70528_REG_RTC_WAKE_START, &wake, 170 - sizeof(wake)); 171 - if (ret) { 172 - dev_err(dev, "Failed to set wake time\n"); 173 - return ret; 174 - } 175 - ret = regmap_bulk_write(r->regmap, BD70528_REG_RTC_ALM_START, &alm, 176 - sizeof(alm)); 177 - if (ret) 178 - dev_err(dev, "Failed to set alarm time\n"); 179 - 180 - return ret; 181 - } 182 - 183 270 static int bd71828_read_alarm(struct device *dev, struct rtc_wkalrm *a) 184 271 { 185 272 int ret; ··· 157 336 return 0; 158 337 } 159 338 160 - static int bd70528_read_alarm(struct device *dev, struct rtc_wkalrm *a) 339 + static int bd71828_set_time(struct device *dev, struct rtc_time *t) 161 340 { 162 - struct bd70528_rtc_alm alm; 163 341 int ret; 164 - struct bd70528_rtc *r = dev_get_drvdata(dev); 165 - 166 - ret = regmap_bulk_read(r->regmap, BD70528_REG_RTC_ALM_START, &alm, 167 - sizeof(alm)); 168 - if (ret) { 169 - dev_err(dev, "Failed to read alarm regs\n"); 170 - return ret; 171 - } 172 - 173 - rtc2tm(&alm.data, &a->time); 174 - a->time.tm_mday = -1; 175 - a->time.tm_mon = -1; 176 - a->time.tm_year = -1; 177 - a->enabled = !(alm.alm_mask & BD70528_MASK_ALM_EN); 178 - a->pending = 0; 179 - 180 - return 0; 181 - } 182 - 183 - static int bd70528_set_time_locked(struct device *dev, struct rtc_time *t) 184 - { 185 - int ret, tmpret, old_states; 186 342 struct bd70528_rtc_data rtc_data; 187 343 struct bd70528_rtc *r = dev_get_drvdata(dev); 188 344 189 - ret = bd70528_disable_rtc_based_timers(r, &old_states); 190 - if (ret) 191 - return ret; 192 - 193 - tmpret = regmap_bulk_read(r->regmap, r->reg_time_start, &rtc_data, 194 - sizeof(rtc_data)); 195 - if (tmpret) { 345 + ret = regmap_bulk_read(r->regmap, r->reg_time_start, &rtc_data, 346 + sizeof(rtc_data)); 347 + if (ret) { 196 348 dev_err(dev, "Failed to read RTC time registers\n"); 197 - goto renable_out; 349 + return ret; 198 350 } 199 351 tm2rtc(t, &rtc_data); 200 352 201 - tmpret = regmap_bulk_write(r->regmap, r->reg_time_start, &rtc_data, 202 - sizeof(rtc_data)); 203 - if (tmpret) { 353 + ret = regmap_bulk_write(r->regmap, r->reg_time_start, &rtc_data, 354 + sizeof(rtc_data)); 355 + if (ret) 204 356 dev_err(dev, "Failed to set RTC time\n"); 205 - goto renable_out; 206 - } 207 357 208 - renable_out: 209 - ret = bd70528_re_enable_rtc_based_timers(r, old_states); 210 - if (tmpret) 211 - ret = tmpret; 212 - 213 - return ret; 214 - } 215 - 216 - static int bd71828_set_time(struct device *dev, struct rtc_time *t) 217 - { 218 - return bd70528_set_time_locked(dev, t); 219 - } 220 - 221 - static int bd70528_set_time(struct device *dev, struct rtc_time *t) 222 - { 223 - int ret; 224 - struct bd70528_rtc *r = dev_get_drvdata(dev); 225 - 226 - bd70528_wdt_lock(r->parent); 227 - ret = bd70528_set_time_locked(dev, t); 228 - bd70528_wdt_unlock(r->parent); 229 358 return ret; 230 359 } 231 360 ··· 198 427 return 0; 199 428 } 200 429 201 - static int bd70528_alm_enable(struct device *dev, unsigned int enabled) 202 - { 203 - int ret; 204 - unsigned int enableval = BD70528_MASK_ALM_EN; 205 - struct bd70528_rtc *r = dev_get_drvdata(dev); 206 - 207 - if (enabled) 208 - enableval = 0; 209 - 210 - bd70528_wdt_lock(r->parent); 211 - ret = bd70528_set_wake(r->parent, enabled, NULL); 212 - if (ret) { 213 - dev_err(dev, "Failed to change wake state\n"); 214 - goto out_unlock; 215 - } 216 - ret = regmap_update_bits(r->regmap, BD70528_REG_RTC_ALM_MASK, 217 - BD70528_MASK_ALM_EN, enableval); 218 - if (ret) 219 - dev_err(dev, "Failed to change alarm state\n"); 220 - 221 - out_unlock: 222 - bd70528_wdt_unlock(r->parent); 223 - return ret; 224 - } 225 - 226 430 static int bd71828_alm_enable(struct device *dev, unsigned int enabled) 227 431 { 228 432 int ret; ··· 215 469 216 470 return ret; 217 471 } 218 - 219 - static const struct rtc_class_ops bd70528_rtc_ops = { 220 - .read_time = bd70528_get_time, 221 - .set_time = bd70528_set_time, 222 - .read_alarm = bd70528_read_alarm, 223 - .set_alarm = bd70528_set_alarm, 224 - .alarm_irq_enable = bd70528_alm_enable, 225 - }; 226 472 227 473 static const struct rtc_class_ops bd71828_rtc_ops = { 228 474 .read_time = bd70528_get_time, ··· 241 503 struct rtc_device *rtc; 242 504 int irq; 243 505 unsigned int hr; 244 - bool enable_main_irq = false; 245 506 u8 hour_reg; 246 507 enum rohm_chip_type chip = platform_get_device_id(pdev)->driver_data; 247 508 ··· 255 518 } 256 519 257 520 bd_rtc->dev = &pdev->dev; 521 + rtc_ops = &bd71828_rtc_ops; 258 522 259 523 switch (chip) { 260 - case ROHM_CHIP_TYPE_BD70528: 261 - bd_rtc->parent = dev_get_drvdata(pdev->dev.parent); 262 - if (!bd_rtc->parent) { 263 - dev_err(&pdev->dev, "No MFD data\n"); 264 - return -EINVAL; 265 - } 266 - irq_name = "bd70528-rtc-alm"; 267 - bd_rtc->has_rtc_timers = true; 268 - bd_rtc->reg_time_start = BD70528_REG_RTC_START; 269 - hour_reg = BD70528_REG_RTC_HOUR; 270 - enable_main_irq = true; 271 - rtc_ops = &bd70528_rtc_ops; 272 - break; 273 524 case ROHM_CHIP_TYPE_BD71815: 274 525 irq_name = "bd71815-rtc-alm-0"; 275 526 bd_rtc->reg_time_start = BD71815_REG_RTC_START; ··· 274 549 */ 275 550 bd_rtc->bd718xx_alm_block_start = BD71815_REG_RTC_ALM_START; 276 551 hour_reg = BD71815_REG_HOUR; 277 - rtc_ops = &bd71828_rtc_ops; 278 552 break; 279 553 case ROHM_CHIP_TYPE_BD71828: 280 554 irq_name = "bd71828-rtc-alm-0"; 281 555 bd_rtc->reg_time_start = BD71828_REG_RTC_START; 282 556 bd_rtc->bd718xx_alm_block_start = BD71828_REG_RTC_ALM_START; 283 557 hour_reg = BD71828_REG_RTC_HOUR; 284 - rtc_ops = &bd71828_rtc_ops; 285 558 break; 286 559 default: 287 560 dev_err(&pdev->dev, "Unknown chip\n"); ··· 334 611 if (ret) 335 612 return ret; 336 613 337 - /* 338 - * BD70528 irq controller is not touching the main mask register. 339 - * So enable the RTC block interrupts at main level. We can just 340 - * leave them enabled as irq-controller should disable irqs 341 - * from sub-registers when IRQ is disabled or freed. 342 - */ 343 - if (enable_main_irq) { 344 - ret = regmap_update_bits(bd_rtc->regmap, 345 - BD70528_REG_INT_MAIN_MASK, 346 - BD70528_INT_RTC_MASK, 0); 347 - if (ret) { 348 - dev_err(&pdev->dev, "Failed to enable RTC interrupts\n"); 349 - return ret; 350 - } 351 - } 352 - 353 614 return devm_rtc_register_device(rtc); 354 615 } 355 616 356 617 static const struct platform_device_id bd718x7_rtc_id[] = { 357 - { "bd70528-rtc", ROHM_CHIP_TYPE_BD70528 }, 358 618 { "bd71828-rtc", ROHM_CHIP_TYPE_BD71828 }, 359 619 { "bd71815-rtc", ROHM_CHIP_TYPE_BD71815 }, 360 620 { }, ··· 355 649 module_platform_driver(bd70528_rtc); 356 650 357 651 MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>"); 358 - MODULE_DESCRIPTION("ROHM BD70528 and BD71828 PMIC RTC driver"); 652 + MODULE_DESCRIPTION("ROHM BD71828 and BD71815 PMIC RTC driver"); 359 653 MODULE_LICENSE("GPL"); 360 654 MODULE_ALIAS("platform:bd70528-rtc");