Re: [PATCH 2/4] MFD: RK808: Add new mfd device for RK808
From: Mark Brown
Date: Sun Aug 17 2014 - 10:14:25 EST
On Sun, Aug 17, 2014 at 09:58:25AM +0800, Chris Zhong wrote:
> +static void rk808_device_shutdown(void)
> +{
> + int ret;
> + struct rk808 *rk808 = g_rk808;
> +
> + if (!rk808) {
> + dev_err(rk808->dev, "%s have no g_rk808\n", __func__);
> + return;
> + }
This is a bit dodgy but I can't think of a better way of doing it :/
> +
> + ret = regmap_update_bits(rk808->regmap,
> + RK808_INT_STS_MSK_REG1,
> + (0x3 << 5), (0x3 << 5));
> + /* close rtc int when power off */
> + ret = regmap_update_bits(rk808->regmap,
> + RK808_RTC_INT_REG,
> + (0x3 << 2), 0);
> + /* close rtc int when power off */
> + ret = regmap_update_bits(rk808->regmap,
> + RK808_DEVCTRL_REG,
> + (0x1 << 3), (0x1 << 3));
> + if (ret < 0)
> + dev_err(rk808->dev, "rk808 power off error!\n");
Defines for these bits would be good, though if this turns off the RTC
alarm then it might be better not to do it - one thing people do with
RTC alarms is use them to wake the system up from deep sleep.
> + while (1)
> + wfi();
> +}
Just let the kernel shut down by itself - or is that last write a system
power off request?
> + ret = regmap_read(rk808->regmap, 0x2f, &val);
> + if (ret < 0) {
> + dev_err(rk808->dev, "The device is not rk808 %d\n", ret);
> + return ret;
> + }
That error message is misleading - an error from regmap_read() means
that I/O failed, usually "device is not rk808" would mean that you'd
read back and ID register on the device and it didn't match what was
expected.
Attachment:
signature.asc
Description: Digital signature