BPI-R2 already has an on-board RTC


(Frank W.) #13

is not active and not set in defconfig…after activating it does poweroff :slight_smile:

which clocks do you mean?


#14

# Clock driver for MediaTek SoC
#
CONFIG_COMMON_CLK_MEDIATEK=y
CONFIG_COMMON_CLK_MT2701=y
# CONFIG_COMMON_CLK_MT2701_MMSYS is not set
# CONFIG_COMMON_CLK_MT2701_IMGSYS is not set
# CONFIG_COMMON_CLK_MT2701_VDECSYS is not set
CONFIG_COMMON_CLK_MT2701_HIFSYS=y
CONFIG_COMMON_CLK_MT2701_ETHSYS=y
# CONFIG_COMMON_CLK_MT2701_BDPSYS is not set
# CONFIG_COMMON_CLK_MT2701_AUDSYS is not set
# CONFIG_COMMON_CLK_MT2701_G3DSYS is not set
CONFIG_COMMON_CLK_MT7622=y
# CONFIG_COMMON_CLK_MT7622_ETHSYS is not set
# CONFIG_COMMON_CLK_MT7622_HIFSYS is not set
# CONFIG_COMMON_CLK_MT7622_AUDSYS is not set
CONFIG_COMMON_CLK_MT8135=y
CONFIG_COMMON_CLK_MT8173=y
# CONFIG_HWSPINLOCK is not set

(Frank W.) #15

which clocks do you need? mt7622 is for other soc, 8135 and 8173 same…

mmsys,imgsys,vdecsysg3dsys are for hdmi/drm (imho not included in 4.19)


#16

I only noticed it compared to 4.14-main.


(Frank W.) #17

ok, 4.14 currently supports much more features like hdmi (second gmac, hnat, …) which may cause more options…basic hdmi-patches (by mediatek) maybe included, but at least dts-nodes and fbdev is missing


(Frank W.) #18

@jofri: if i activate rtc_class=y (see my defconfig in 4.19-rc) i get the following errors:

  CC      drivers/rtc/rtc-mt6397.o
In file included from drivers/rtc/rtc-mt6397.c:13:
./include/linux/mfd/mt6397/core.h:59:15: error: field 'irqlock' has incomplete type
  struct mutex irqlock;
               ^~~~~~~
drivers/rtc/rtc-mt6397.c:320:34: error: array type has incomplete element type 'struct of_device_id'
 static const struct of_device_id mt6397_rtc_of_match[] = {
                                  ^~~~~~~~~~~~~~~~~~~
drivers/rtc/rtc-mt6397.c:321:4: error: field name not in record or union initializer
  { .compatible = "mediatek,mt6323-rtc", },
    ^
drivers/rtc/rtc-mt6397.c:321:4: note: (near initialization for 'mt6397_rtc_of_match')
drivers/rtc/rtc-mt6397.c:322:4: error: field name not in record or union initializer
  { .compatible = "mediatek,mt6397-rtc", },
    ^
drivers/rtc/rtc-mt6397.c:322:4: note: (near initialization for 'mt6397_rtc_of_match')
drivers/rtc/rtc-mt6397.c:320:34: warning: 'mt6397_rtc_of_match' defined but not used [-Wunused-variable]
 static const struct of_device_id mt6397_rtc_of_match[] = {
                                  ^~~~~~~~~~~~~~~~~~~
scripts/Makefile.build:307: recipe for target 'drivers/rtc/rtc-mt6397.o' failed
make[2]: *** [drivers/rtc/rtc-mt6397.o] Error 1
scripts/Makefile.build:548: recipe for target 'drivers/rtc' failed
make[1]: *** [drivers/rtc] Error 2
Makefile:1057: recipe for target 'drivers' failed
make: *** [drivers] Error 2

can you take a look at this? First one seems to be missing include

https://elixir.bootlin.com/linux/v4.19-rc1/source/include/linux/mutex.h#L53


(Frank W.) #19

fixed


#20
diff --git a/drivers/rtc/rtc-mt6397.c b/drivers/rtc/rtc-mt6397.c
index 1ebeaaf11dfa..c3ed1e660f85 100644
--- a/drivers/rtc/rtc-mt6397.c
+++ b/drivers/rtc/rtc-mt6397.c
@@ -17,6 +17,7 @@
 #include <linux/regmap.h>
 #include <linux/rtc.h>
 #include <linux/mfd/mt6397/rtc.h>
+#include <linux/mod_devicetable.h>

 static int mtk_rtc_write_trigger(struct mt6397_rtc *rtc)
 {
diff --git a/include/linux/mfd/mt6397/core.h b/include/linux/mfd/mt6397/core.h
index d678f526e498..0425c68cc187 100644
--- a/include/linux/mfd/mt6397/core.h
+++ b/include/linux/mfd/mt6397/core.h
@@ -15,6 +15,8 @@
 #ifndef __MFD_MT6397_CORE_H__
 #define __MFD_MT6397_CORE_H__

+#include <linux/mutex.h>
+
 enum mt6397_irq_numbers {
        MT6397_IRQ_SPKL_AB = 0,
        MT6397_IRQ_SPKR_AB,
(END)

(Frank W.) #21

thanks, like my fix :wink:


(Frank W.) #22

@jofri

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

-CONFIG_RTC_DRV_MT6397=m
+CONFIG_RTC_DRV_MT6397=y

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


#23

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.

Greetings


(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?


#26

Hello,

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

https://github.com/frank-w/BPI-R2-4.14/commit/981dbf745c8c80300707ee2a5c1e25189b51a2e6.patch

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.


#28

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?


#30

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.

no


(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

event=button/power

action=/sbin/poweroff

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?