> Subject: Re: [PATCH v2 3/4] rtc: bbnsm: Add the bbnsm rtc support > > On 26/12/2022 10:39:41+0800, Jacky Bai wrote: > > +static int bbnsm_rtc_read_time(struct device *dev, struct rtc_time > > +*tm) { > > + struct bbnsm_rtc *bbnsm = dev_get_drvdata(dev); > > + unsigned long time; > > + u32 val; > > + > > + regmap_read(bbnsm->regmap, BBNSM_CTRL, &val); > > + if ((val & RTC_EN_MSK) != RTC_EN) { > > + dev_warn(dev, "RTC is not enabled, time is invalid!\n"); > > I don't think this message is necessary. > Ok, will remove it. > > + return -EINVAL; > > + } > > + > > + time = bbnsm_read_counter(bbnsm); > > + rtc_time64_to_tm(time, tm); > > + > > + return 0; > > +} > > + > > [...] > > > +static int bbnsm_rtc_probe(struct platform_device *pdev) { > > + struct bbnsm_rtc *bbnsm; > > + int ret; > > + > > + bbnsm = devm_kzalloc(&pdev->dev, sizeof(*bbnsm), GFP_KERNEL); > > + if (!bbnsm) > > + return -ENOMEM; > > + > > + bbnsm->rtc = devm_rtc_allocate_device(&pdev->dev); > > + > > + bbnsm->regmap = > syscon_regmap_lookup_by_phandle(pdev->dev.of_node, > "nxp,bbnsm-regmap"); > > + if (IS_ERR(bbnsm->regmap)) { > > + dev_err(&pdev->dev, "bbnsm get regmap failed\n"); > > Maybe this should be a dev_dbg? Fine, will fix in V3. BR > > > + return PTR_ERR(bbnsm->regmap); > > + } > > + > > + bbnsm->irq = platform_get_irq(pdev, 0); > > + if (bbnsm->irq < 0) > > + return bbnsm->irq; > > + > > + platform_set_drvdata(pdev, bbnsm); > > + > > + /* clear all the pending events */ > > + regmap_write(bbnsm->regmap, BBNSM_EVENTS, 0x7A); > > + > > + device_init_wakeup(&pdev->dev, true); > > + dev_pm_set_wake_irq(&pdev->dev, bbnsm->irq); > > + > > + ret = devm_request_irq(&pdev->dev, bbnsm->irq, > bbnsm_rtc_irq_handler, > > + IRQF_SHARED, "rtc alarm", &pdev->dev); > > + if (ret) { > > + dev_err(&pdev->dev, "failed to request irq %d: %d\n", > > + bbnsm->irq, ret); > > + return ret; > > + } > > + > > + bbnsm->rtc->ops = &bbnsm_rtc_ops; > > + bbnsm->rtc->range_max = U32_MAX; > > + > > + return devm_rtc_register_device(bbnsm->rtc); > > +} > > + > > +static const struct of_device_id bbnsm_dt_ids[] = { > > + { .compatible = "nxp,bbnsm-rtc", }, > > + { /* sentinel */ }, > > +}; > > +MODULE_DEVICE_TABLE(of, bbnsm_dt_ids); > > + > > +static struct platform_driver bbnsm_rtc_driver = { > > + .driver = { > > + .name = "bbnsm_rtc", > > + .of_match_table = bbnsm_dt_ids, > > + }, > > + .probe = bbnsm_rtc_probe, > > +}; > > +module_platform_driver(bbnsm_rtc_driver); > > + > > +MODULE_AUTHOR("Jacky Bai <ping.bai@xxxxxxx>"); > > +MODULE_DESCRIPTION("NXP BBNSM RTC Driver"); > MODULE_LICENSE("GPL"); > > -- > > 2.37.1 > > > > -- > Alexandre Belloni, co-owner and COO, Bootlin > Embedded Linux and Kernel engineering > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbootlin > .com%2F&data=05%7C01%7Cping.bai%40nxp.com%7C2a4980d832274ceac4 > e908dae8c4ec12%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C6 > 38078229719156877%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwM > DAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C% > 7C&sdata=nfDGoPytTNjULmOzC8IMF8r%2FrHiNJehsEls6m3lPsGc%3D&reser > ved=0