Skip to contentSkip to conversation

Support RTC on Malta

PATCH Superseded Tiejun Chen 2 participants 8 messages Oct 30, 2008 – Apr 14, 2009 MIPS

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Support RTC on Malta

To create platform device for RTC to call platform driver successfully.

---
 arch/mips/configs/malta_defconfig |    4 +-
 arch/mips/mti-malta/Makefile      |    2 +-
 arch/mips/mti-malta/malta-rtc.c   |   73 +++++++++++++++++++++++++++++++++++++
 3 files changed, 76 insertions(+), 3 deletions(-)
 create mode 100644 arch/mips/mti-malta/malta-rtc.c
arch/mips/configs/malta_defconfig +2 -2
index 74daa0c..f84bdf6 100644
@@ -1126,7 +1126,6 @@ CONFIG_LEGACY_PTY_COUNT=256
 # CONFIG_IPMI_HANDLER is not set
 # CONFIG_WATCHDOG is not set
 CONFIG_HW_RANDOM=m
-CONFIG_RTC=y
 # CONFIG_R3964 is not set
 # CONFIG_APPLICOM is not set
 # CONFIG_DRM is not set
@@ -1199,7 +1198,8 @@ CONFIG_USB_ARCH_HAS_EHCI=y
 # CONFIG_MMC is not set
 # CONFIG_NEW_LEDS is not set
 # CONFIG_INFINIBAND is not set
-# CONFIG_RTC_CLASS is not set
+CONFIG_RTC_CLASS=y
+CONFIG_RTC_DRV_CMOS=y
 
 #
 # DMA Engine support
arch/mips/mti-malta/Makefile +1 -1
index cef2db8..26284fc 100644
@@ -9,7 +9,7 @@ obj-y				:= malta-amon.o malta-cmdline.o \
 				   malta-display.o malta-init.o malta-int.o \
 				   malta-memory.o malta-mtd.o \
 				   malta-platform.o malta-reset.o \
-				   malta-setup.o malta-time.o
+				   malta-setup.o malta-time.o malta-rtc.o
 
 obj-$(CONFIG_EARLY_PRINTK)	+= malta-console.o
 obj-$(CONFIG_PCI)		+= malta-pci.o
arch/mips/mti-malta/malta-rtc.c new file +73 -0

73 lines not on this page · raw message

Signature · 1 line
1.5.5.1
#1 lore raw

PATCH 1/1 Reserve stack/heap area for RP program

When you want to run a program on RP it's necessary to reserve corresponding stack/heap area of that program.

---
 arch/mips/mti-malta/malta-memory.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
arch/mips/mti-malta/malta-memory.c +13 -0
index 61888ff..d8c0834 100644
@@ -87,6 +87,19 @@ static struct prom_pmemblock * __init prom_getmdesc(void)
 	else
 		memsize = physical_memsize;
 
+#ifdef CONFIG_MIPS_VPE_LOADER
+	/*
+         * The default DFLT_STACK_SIZE and DFLT_HEAP_SIZE will be known 
+         * from sde-kit. Actually it should define according to the different RP
+         * application. In the future we might want to improve it.
+         */
+#define DFLT_STACK_SIZE (65536)
+#define DFLT_HEAP_SIZE  (1048576) 
+        /* Reserve area used by building stack and heap for running RP. 
+         */
+        memsize -= (DFLT_HEAP_SIZE + DFLT_STACK_SIZE + PAGE_SIZE);
+#endif
+
 	memset(mdesc, 0, sizeof(mdesc));
 
 	mdesc[0].type = yamon_dontuse;
Signature · 1 line
1.5.5.1
#2 lore raw

Re: [PATCH] Reserve stack/heap area for RP program

Quoted 2 lines · Tiejun Chen

When you want to run a program on RP it's necessary to reserve corresponding stack/heap area of that program.

The official method is to pass a mem= argument when booting the kernel and adjust by the amount required. Which certainly is more flexible than having to hack a constant deeply hidden in the kernel code as in your proposed patch.

Ralf

#3 lore raw

Re: [PATCH] Reserve stack/heap area for RP program

Quoted 10 lines · Ralf Baechle
Quoted 2 lines · Tiejun Chen

When you want to run a program on RP it's necessary to reserve corresponding stack/heap area of that program.

The official method is to pass a mem= argument when booting the kernel and adjust by the amount required. Which certainly is more flexible than having to hack a constant deeply hidden in the kernel code as in your proposed patch.

This issue is not related to pass "mem= " if enable CONFIG_MIPS_VPE_LOADER_TOM. That way is only load RP on the hidden memory to run. Anyway we still not reserve necessary memory for stack/heap of RP which may be overwrite by AP such as linux so you will found kernel crash.

Quoted 2 lines

Ralf

#4 lore raw

Re: [PATCH] Reserve stack/heap area for RP program

Quoted 11 lines · tiejun.chen
Quoted 9 lines · Ralf Baechle
Quoted 2 lines · Tiejun Chen

When you want to run a program on RP it's necessary to reserve corresponding stack/heap area of that program.

The official method is to pass a mem= argument when booting the kernel and adjust by the amount required. Which certainly is more flexible than having to hack a constant deeply hidden in the kernel code as in your proposed patch.

Quoted 4 lines

This issue is not related to pass "mem= " if enable CONFIG_MIPS_VPE_LOADER_TOM. That way is only load RP on the hidden memory to run. Anyway we still not reserve necessary memory for stack/heap of RP which may be overwrite by AP such as linux so you will found kernel crash.

Ralf,

Can you give me some suggestions?

Best Regards
Tiejun

Quoted 6 lines
Quoted 3 lines

Ralf

#5 lore raw
In reply to Tiejun Chen

On Thu, Oct 30, 2008 at 07:15:44PM +0800, Tiejun Chen wrote:

Looks reasonable but I have a few comments:

arch/mips/mti-malta/Makefile obj-y := malta-amon.o malta-cmdline.o \ · line 12

Quoted 10 lines
arch/mips/mti-malta/Makefile +1 -1
index cef2db8..26284fc 100644
@@ -9,7 +9,7 @@ obj-y				:= malta-amon.o malta-cmdline.o \
 				   malta-display.o malta-init.o malta-int.o \
 				   malta-memory.o malta-mtd.o \
 				   malta-platform.o malta-reset.o \
-				   malta-setup.o malta-time.o
+				   malta-setup.o malta-time.o malta-rtc.o

Could you please fold malta-rtc.c into the existing malta-platform.c instead of creating a new file?

Quoted 8 lines
arch/mips/mti-malta/Makefile +6 -0
+++ b/arch/mips/mti-malta/malta-rtc.c
@@ -0,0 +1,73 @@
 
+	struct platform_device *pdev;
+	int ret;
+
+	pdev = platform_device_alloc("rtc_cmos", -1);
+	if (!pdev)

arch/mips/mti-malta/Makefile

Quoted 10 lines
arch/mips/mti-malta/Makefile +10 -0
+		return -ENOMEM;
+
+	ret = platform_device_add_resources(pdev, malta_platform_rtc_resource,
+	                                       ARRAY_SIZE(malta_platform_rtc_resource));
+	if (ret)
+		goto err;
+
+	ret = platform_device_add(pdev);
+	if (ret)
+		goto err;

You can simplify this a bit by using a static struct platform_device like:

static struct platform_device rtc_device = {
.name = "rtc_cmos",
.id = -1,
.resource = &malta_platform_rtc_resource,
.num_resources = ARRAY_SIZE(malta_platform_rtc_resource),
};

arch/mips/mti-malta/Makefile

Quoted 6 lines
arch/mips/mti-malta/Makefile +6 -0
+
+	/* Try setting rtc as BCD mode to support
+	 * current alarm code if possible.
+	 */
+	if (!RTC_ALWAYS_BCD)
+		CMOS_WRITE(CMOS_READ(RTC_CONTROL) & ~RTC_DM_BINARY, RTC_CONTROL);

RTC_ALWAYS_BCD is 0, so the if condition is always true and the if can be eleminated.

Can you fix that?

Ralf

#6 lore raw
Quoted 4 lines · Ralf Baechle

On Thu, Oct 30, 2008 at 07:15:44PM +0800, Tiejun Chen wrote:

Looks reasonable but I have a few comments:

Quoted 14 lines

arch/mips/mti-malta/Makefile obj-y := malta-amon.o malta-cmdline.o \ · line 12

Quoted 10 lines
arch/mips/mti-malta/Makefile +1 -1
index cef2db8..26284fc 100644
@@ -9,7 +9,7 @@ obj-y				:= malta-amon.o malta-cmdline.o \
 				   malta-display.o malta-init.o malta-int.o \
 				   malta-memory.o malta-mtd.o \
 				   malta-platform.o malta-reset.o \
-				   malta-setup.o malta-time.o
+				   malta-setup.o malta-time.o malta-rtc.o

Could you please fold malta-rtc.c into the existing malta-platform.c instead of creating a new file?

Good idea and done.

Quoted 12 lines
Quoted 12 lines
arch/mips/mti-malta/Makefile +10 -0
+++ b/arch/mips/mti-malta/malta-rtc.c
@@ -0,0 +1,73 @@
 
+	struct platform_device *pdev;
+	int ret;
+
+	pdev = platform_device_alloc("rtc_cmos", -1);
+	if (!pdev)
+		return -ENOMEM;
+
+	ret = platform_device_add_resources(pdev, malta_platform_rtc_resource,
+	                                       ARRAY_SIZE(malta_platform_rtc_resource));
Quoted 9 lines

arch/mips/mti-malta/Makefile

Quoted 6 lines
arch/mips/mti-malta/Makefile +6 -0
+	if (ret)
+		goto err;
+
+	ret = platform_device_add(pdev);
+	if (ret)
+		goto err;

You can simplify this a bit by using a static struct platform_device like:

I generated another patch to your separate email temporarily. I'll cc here after you confirm if the file head is valid.

Quoted 7 lines

static struct platform_device rtc_device = {
.name = "rtc_cmos",
.id = -1,
.resource = &malta_platform_rtc_resource,
.num_resources = ARRAY_SIZE(malta_platform_rtc_resource),
};

Quoted 10 lines

arch/mips/mti-malta/Makefile

Quoted 6 lines
arch/mips/mti-malta/Makefile +6 -0
+
+	/* Try setting rtc as BCD mode to support
+	 * current alarm code if possible.
+	 */
+	if (!RTC_ALWAYS_BCD)
+		CMOS_WRITE(CMOS_READ(RTC_CONTROL) & ~RTC_DM_BINARY, RTC_CONTROL);

RTC_ALWAYS_BCD is 0, so the if condition is always true and the if can be eleminated.

Ohh... I guess we'd better use this to track something once this macro may be changed in the future.

Best Regards
Tiejun

Quoted 4 lines

Can you fix that?

Ralf

#7 lore raw
In reply to Ralf Baechle
Quoted 56 lines · Ralf Baechle

On Thu, Oct 30, 2008 at 07:15:44PM +0800, Tiejun Chen wrote:

Looks reasonable but I have a few comments:

arch/mips/mti-malta/Makefile obj-y := malta-amon.o malta-cmdline.o \ · line 12

Quoted 10 lines
arch/mips/mti-malta/Makefile +1 -1
index cef2db8..26284fc 100644
@@ -9,7 +9,7 @@ obj-y				:= malta-amon.o malta-cmdline.o \
 				   malta-display.o malta-init.o malta-int.o \
 				   malta-memory.o malta-mtd.o \
 				   malta-platform.o malta-reset.o \
-				   malta-setup.o malta-time.o
+				   malta-setup.o malta-time.o malta-rtc.o

Could you please fold malta-rtc.c into the existing malta-platform.c instead of creating a new file?

Quoted 8 lines
arch/mips/mti-malta/Makefile +6 -0
+++ b/arch/mips/mti-malta/malta-rtc.c
@@ -0,0 +1,73 @@
 
+	struct platform_device *pdev;
+	int ret;
+
+	pdev = platform_device_alloc("rtc_cmos", -1);
+	if (!pdev)

arch/mips/mti-malta/Makefile

Quoted 10 lines
arch/mips/mti-malta/Makefile +10 -0
+		return -ENOMEM;
+
+	ret = platform_device_add_resources(pdev, malta_platform_rtc_resource,
+	                                       ARRAY_SIZE(malta_platform_rtc_resource));
+	if (ret)
+		goto err;
+
+	ret = platform_device_add(pdev);
+	if (ret)
+		goto err;

You can simplify this a bit by using a static struct platform_device like:

static struct platform_device rtc_device = {
.name = "rtc_cmos",
.id = -1,
.resource = &malta_platform_rtc_resource,
.num_resources = ARRAY_SIZE(malta_platform_rtc_resource),
};

arch/mips/mti-malta/Makefile

Quoted 6 lines
arch/mips/mti-malta/Makefile +6 -0
+
+	/* Try setting rtc as BCD mode to support
+	 * current alarm code if possible.
+	 */
+	if (!RTC_ALWAYS_BCD)
+		CMOS_WRITE(CMOS_READ(RTC_CONTROL) & ~RTC_DM_BINARY, RTC_CONTROL);

RTC_ALWAYS_BCD is 0, so the if condition is always true and the if can be eleminated.

Quoted 2 lines

Can you fix that?

Ralf,

I already re-sended another patch, [PATCH v2] Support RTC on Malta.

Best Regards
Tiejun

Quoted 2 lines

Ralf