From: Jacky Bai <ping.bai@nxp.com> To: Alexandre Belloni <alexandre.belloni@bootlin.com> Cc: "lee@kernel.org" <lee@kernel.org>, "robh+dt@kernel.org" <robh+dt@kernel.org>, "krzysztof.kozlowski+dt@linaro.org" <krzysztof.kozlowski+dt@linaro.org>, "shawnguo@kernel.org" <shawnguo@kernel.org>, "s.hauer@pengutronix.de" <s.hauer@pengutronix.de>, "dmitry.torokhov@gmail.com" <dmitry.torokhov@gmail.com>, "a.zummo@towertech.it" <a.zummo@towertech.it>, "devicetree@vger.kernel.org" <devicetree@vger.kernel.org>, "linux-arm-kernel@lists.infradead.org" <linux-arm-kernel@lists.infradead.org>, "linux-input@vger.kernel.org" <linux-input@vger.kernel.org>, "linux-rtc@vger.kernel.org" <linux-rtc@vger.kernel.org>, "kernel@pengutronix.de" <kernel@pengutronix.de>, dl-linux-imx <linux-imx@nxp.com>, "festevam@gmail.com" <festevam@gmail.com> Subject: RE: [PATCH v2 3/4] rtc: bbnsm: Add the bbnsm rtc support Date: Tue, 3 Jan 2023 01:23:53 +0000 [thread overview] Message-ID: <AS8PR04MB8642AE9D87FB0ACF883A1CC887F49@AS8PR04MB8642.eurprd04.prod.outlook.com> (raw) In-Reply-To: <Y6wldnu6+apmnSxJ@mail.local> > 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@nxp.com>"); > > +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
WARNING: multiple messages have this Message-ID (diff)
From: Jacky Bai <ping.bai@nxp.com> To: Alexandre Belloni <alexandre.belloni@bootlin.com> Cc: "lee@kernel.org" <lee@kernel.org>, "robh+dt@kernel.org" <robh+dt@kernel.org>, "krzysztof.kozlowski+dt@linaro.org" <krzysztof.kozlowski+dt@linaro.org>, "shawnguo@kernel.org" <shawnguo@kernel.org>, "s.hauer@pengutronix.de" <s.hauer@pengutronix.de>, "dmitry.torokhov@gmail.com" <dmitry.torokhov@gmail.com>, "a.zummo@towertech.it" <a.zummo@towertech.it>, "devicetree@vger.kernel.org" <devicetree@vger.kernel.org>, "linux-arm-kernel@lists.infradead.org" <linux-arm-kernel@lists.infradead.org>, "linux-input@vger.kernel.org" <linux-input@vger.kernel.org>, "linux-rtc@vger.kernel.org" <linux-rtc@vger.kernel.org>, "kernel@pengutronix.de" <kernel@pengutronix.de>, dl-linux-imx <linux-imx@nxp.com>, "festevam@gmail.com" <festevam@gmail.com> Subject: RE: [PATCH v2 3/4] rtc: bbnsm: Add the bbnsm rtc support Date: Tue, 3 Jan 2023 01:23:53 +0000 [thread overview] Message-ID: <AS8PR04MB8642AE9D87FB0ACF883A1CC887F49@AS8PR04MB8642.eurprd04.prod.outlook.com> (raw) In-Reply-To: <Y6wldnu6+apmnSxJ@mail.local> > 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@nxp.com>"); > > +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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-01-03 1:23 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-12-26 2:39 [PATCH v2 0/4] Add nxp bbnsm module support Jacky Bai 2022-12-26 2:39 ` Jacky Bai 2022-12-26 2:39 ` [PATCH v2 1/4] dt-bindings: mfd: Add nxp bbnsm Jacky Bai 2022-12-26 2:39 ` Jacky Bai 2022-12-26 21:55 ` Rob Herring 2022-12-26 21:55 ` Rob Herring 2022-12-27 1:54 ` Jacky Bai 2022-12-27 1:54 ` Jacky Bai 2022-12-26 2:39 ` [PATCH v2 2/4] input: bbnsm_pwrkey: Add bbnsm power key support Jacky Bai 2022-12-26 2:39 ` Jacky Bai 2022-12-26 2:39 ` [PATCH v2 3/4] rtc: bbnsm: Add the bbnsm rtc support Jacky Bai 2022-12-26 2:39 ` Jacky Bai 2022-12-28 11:16 ` Alexandre Belloni 2022-12-28 11:16 ` Alexandre Belloni 2023-01-03 1:23 ` Jacky Bai [this message] 2023-01-03 1:23 ` Jacky Bai 2022-12-26 2:39 ` [PATCH v2 4/4] arm64: dts: imx93: Add the bbnsm dts node Jacky Bai 2022-12-26 2:39 ` Jacky Bai
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=AS8PR04MB8642AE9D87FB0ACF883A1CC887F49@AS8PR04MB8642.eurprd04.prod.outlook.com \ --to=ping.bai@nxp.com \ --cc=a.zummo@towertech.it \ --cc=alexandre.belloni@bootlin.com \ --cc=devicetree@vger.kernel.org \ --cc=dmitry.torokhov@gmail.com \ --cc=festevam@gmail.com \ --cc=kernel@pengutronix.de \ --cc=krzysztof.kozlowski+dt@linaro.org \ --cc=lee@kernel.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-imx@nxp.com \ --cc=linux-input@vger.kernel.org \ --cc=linux-rtc@vger.kernel.org \ --cc=robh+dt@kernel.org \ --cc=s.hauer@pengutronix.de \ --cc=shawnguo@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.