BPI-R2 already has an on-board RTC

(Frank W.) #21

thanks, like my fix :wink:

(Frank W.) #22


it seems that poweroff from 4.19-rc1 is not compatible with 4.19 final. i have added 2 includes to get it compilable, but board does not poweroff completely

power consumption is 1 W instead of 0.2W and all leds are going in a darker mode, but lit all, also network-leds stay on

also in this strange mode reset-switch does not work

i also changed this because i load kernel from tftp


can help here again? it seems that the main files (drivers/mfd/mt6397-core.c, drivers/rtc/rtc-mt6397.c) are not changed in last time

https://patchwork.kernel.org/patch/10593453/ seems not to be merged…that was my first thought

@moore @linkerosa @Jackzeng can you help here? Something seems to be changed between rc1 and final (or rc7…had same behaviour while testing hdmi)

edit: mhm, it seems that tjis issue depends on any module…if i boot from sd-card with modules poweroff works like expected…if i boot kernel from tftp (only uImage) it does not working


Hello Frank,

So I have now tested 4.19. With me everything is as it should be at boot by sd. With tftp I have not tested, but are you sure that the kernel synonymous to the modules fits. “uname -a” and module-path.


(Frank W.) #24

On tftp i have no modules (load only uimage) so i guess i need any module for this to work…this i want to make builtin. But i don’t know which module it is…the rtc and power are already builtin. Keyboard-pmic should be module for users who have soldered power-switch

(Frank W.) #25

@jofri can you try to make your Patch included in mainline?



do you mean in your master branch?

(Frank W.) #27

i mean making it ready to post to linux-mediatek :wink:

like i did for dsa-patches and will do for fbdev if i get answer from CK Hu :slight_smile:

make a git format-patch and then a scripts/checkpatch.pl


this removes some code and i don’t know why…you have to describe it and maybe split into multiple parts. but when it is in mainline it will be maintained.


Hello Frank,

I inserted poweroff in your branch ‘origin / 4.20-rc’

(last commit 7dfcda746c0d50aae40839327753eda165320f9d)

and tested it with checkpatch.pl without error.

The compiler runs without errors. Unfortunately I can not check the kernel myself, because my R2 is in use elsewhere.

0001-add-doc-and-MAINTAINERS-for-poweroff.patch (4,4 KB) 0002-add-dts-for-poweroff.patch (1,1 KB) 0003-add-driver-and-MAINTAINERS-for-poweroff.patch (15,3 KB)

(Frank W.) #29

Thank you,i test it as far as i can

btw. For multi-patch you need also cover-letter (description what series do) its a textfile beginning with 0000- (patch 0/x) created by format-patch --cover-letter

Is it necessary to remove rtc for poweroff?


Thanks, I’ve learned a lot here. A year ago, I did not start to mess with git. Also docuwiki arouses my interest.At the moment I am dealing with the BPI-W2. This is a big construction site.


(Frank W.) #31

a sorry, you move the code (to rtc.h) not remove it…

btw. i also started with git here with my first kernel (while getting 4.14 running (sd-card issue) )

you should drop my defconfig in your Patch because this does not exist on mainline (and brings warning because i’ve already set option while copy from 4.19)

will now compile and test it…

nano /etc/acpi/events/power



service acpid restart

rebased my 4.20-poweroff to avoid the warning (maybe will cause problems if i want to merge…but will not do this on rc)

(Frank W.) #32

@jofri have you tried to send it to mainline? Any problems? Have you created cover-letter?

(Frank W.) #33

@jofri any idea how to get poweroff working in uboot?

maybe we can implement it like this: https://patchwork.ozlabs.org/patch/1075860/

i don’t know how to convert linux regmap_write to uboot pmic_clrsetbits which seem to do similar

as far as i found in your patches this seems to be the key to power off the board:

which value is pwrc->base ? maybe it’s the same as REG_DEVCTRL for the rk8xx

(Frank W.) #35

pwrc->base should be this (drivers/mfd/mt6397-core.c):

#define MT6323_PWRC_BASE	0x8000

regmap_write(dev,reg,val) is defined here: https://elixir.bootlin.com/linux/v4.19/source/drivers/base/regmap/regmap.c#L1778

writing in uboot:

pmic_reg_write(struct udevice *dev, uint reg, uint value)

maybe i can use this: http://git.denx.de/?p=u-boot.git;a=blob;f=drivers/power/domain/mtk-power-domain.c;h=c67e8804b16f9355820882d95f30c4330ddef640;hb=9dec738a8b843bcdcf22ed3e11c59255e9f79d2b#l258 ?

currently it seems there is no pmic implemented yet, so i don’t know how i can get the device to set the register-value :frowning:

(Frank W.) #36

Mhm…uboot has also regmap_write…but how to get the regmap (first param)? I found no use in mt7623 patches in uboot,but regmap-config-option is set


In kernel the regmap is defined/allocated in probe

Imho i only need this:

struct mt6397_chip *mt6397_chip = dev_get_drvdata(pdev->dev.parent);

how to get the pdev (passed to probe) in uboot and where does dev_get_drvdata reads the data?

Imho i need to define a platform-device in dts and a platform-driver struct,something like this:

static struct platform_driver mt6397_driver = {
    .probe = mt6397_probe,
    .remove = mt6397_remove,
    .driver = {
        .name = "mt6397",
        .of_match_table = of_mt6397_match

But i still don’t understand where the regmap getting its data…here the parent-dev is used…this is the mt6323-node…maybe there is a shorter way without creating the full mt6323-node