* [PATCH] Support RTC on Malta
@ 2008-10-30 11:15 Tiejun Chen
2008-10-30 11:15 ` [PATCH] Reserve stack/heap area for RP program Tiejun Chen
2008-10-30 12:05 ` [PATCH] Support RTC on Malta Ralf Baechle
0 siblings, 2 replies; 8+ messages in thread
From: Tiejun Chen @ 2008-10-30 11:15 UTC (permalink / raw)
To: linux-mips, ralf; +Cc: Tiejun Chen
To create platform device for RTC to call platform driver successfully.
Signed-off-by: Tiejun Chen <tiejun.chen@windriver.com>
---
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
diff --git a/arch/mips/configs/malta_defconfig b/arch/mips/configs/malta_defconfig
index 74daa0c..f84bdf6 100644
--- a/arch/mips/configs/malta_defconfig
+++ b/arch/mips/configs/malta_defconfig
@@ -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
diff --git a/arch/mips/mti-malta/Makefile b/arch/mips/mti-malta/Makefile
index cef2db8..26284fc 100644
--- a/arch/mips/mti-malta/Makefile
+++ b/arch/mips/mti-malta/Makefile
@@ -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
diff --git a/arch/mips/mti-malta/malta-rtc.c b/arch/mips/mti-malta/malta-rtc.c
new file mode 100644
index 0000000..b987c31
--- /dev/null
+++ b/arch/mips/mti-malta/malta-rtc.c
@@ -0,0 +1,73 @@
+/*
+ * Registration of Malta RTC platform device.
+ *
+ * Copyright (C) 2008 Tiejun Chen <tiejun.chen@windriver.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <linux/mc146818rtc.h>
+#include <linux/platform_device.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/ioport.h>
+
+static struct resource malta_platform_rtc_resource[] __initdata = {
+ {
+ .start = RTC_PORT(0),
+ .end = RTC_PORT(7),
+ .flags = IORESOURCE_IO,
+ },
+ {
+ .start = RTC_IRQ,
+ .end = RTC_IRQ,
+ .flags = IORESOURCE_IRQ,
+ },
+};
+
+static __init int malta_platform_rtc_add(void)
+{
+ 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));
+ if (ret)
+ goto err;
+
+ ret = platform_device_add(pdev);
+ if (ret)
+ goto err;
+
+ /* 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);
+
+ return 0;
+
+err:
+ platform_device_put(pdev);
+
+ return ret;
+}
+
+device_initcall(malta_platform_rtc_add);
+
--
1.5.5.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH] Reserve stack/heap area for RP program
2008-10-30 11:15 [PATCH] Support RTC on Malta Tiejun Chen
@ 2008-10-30 11:15 ` Tiejun Chen
2008-10-30 12:17 ` Ralf Baechle
2008-10-30 12:05 ` [PATCH] Support RTC on Malta Ralf Baechle
1 sibling, 1 reply; 8+ messages in thread
From: Tiejun Chen @ 2008-10-30 11:15 UTC (permalink / raw)
To: linux-mips, ralf; +Cc: Tiejun Chen
When you want to run a program on RP it's necessary to reserve corresponding stack/heap
area of that program.
Signed-off-by: Tiejun Chen <tiejun.chen@windriver.com>
---
arch/mips/mti-malta/malta-memory.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/arch/mips/mti-malta/malta-memory.c b/arch/mips/mti-malta/malta-memory.c
index 61888ff..d8c0834 100644
--- a/arch/mips/mti-malta/malta-memory.c
+++ b/arch/mips/mti-malta/malta-memory.c
@@ -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;
--
1.5.5.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] Reserve stack/heap area for RP program
2008-10-30 11:15 ` [PATCH] Reserve stack/heap area for RP program Tiejun Chen
@ 2008-10-30 12:17 ` Ralf Baechle
2008-10-31 1:42 ` tiejun.chen
0 siblings, 1 reply; 8+ messages in thread
From: Ralf Baechle @ 2008-10-30 12:17 UTC (permalink / raw)
To: Tiejun Chen; +Cc: linux-mips
On Thu, Oct 30, 2008 at 07:15:45PM +0800, Tiejun Chen wrote:
> 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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Reserve stack/heap area for RP program
2008-10-30 12:17 ` Ralf Baechle
@ 2008-10-31 1:42 ` tiejun.chen
2008-11-03 11:18 ` tiejun.chen
0 siblings, 1 reply; 8+ messages in thread
From: tiejun.chen @ 2008-10-31 1:42 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips
Ralf Baechle wrote:
> On Thu, Oct 30, 2008 at 07:15:45PM +0800, Tiejun Chen wrote:
>
>> 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.
> Ralf
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Reserve stack/heap area for RP program
2008-10-31 1:42 ` tiejun.chen
@ 2008-11-03 11:18 ` tiejun.chen
0 siblings, 0 replies; 8+ messages in thread
From: tiejun.chen @ 2008-11-03 11:18 UTC (permalink / raw)
To: tiejun.chen; +Cc: Ralf Baechle, linux-mips
tiejun.chen wrote:
> Ralf Baechle wrote:
>> On Thu, Oct 30, 2008 at 07:15:45PM +0800, Tiejun Chen wrote:
>>
>>> 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.
Ralf,
Can you give me some suggestions?
Best Regards
Tiejun
>
>> Ralf
>>
>
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Support RTC on Malta
2008-10-30 11:15 [PATCH] Support RTC on Malta Tiejun Chen
2008-10-30 11:15 ` [PATCH] Reserve stack/heap area for RP program Tiejun Chen
@ 2008-10-30 12:05 ` Ralf Baechle
2008-10-31 6:44 ` tiejun.chen
2008-11-26 1:19 ` tiejun.chen
1 sibling, 2 replies; 8+ messages in thread
From: Ralf Baechle @ 2008-10-30 12:05 UTC (permalink / raw)
To: Tiejun Chen; +Cc: linux-mips
On Thu, Oct 30, 2008 at 07:15:44PM +0800, Tiejun Chen wrote:
Looks reasonable but I have a few comments:
> diff --git a/arch/mips/mti-malta/Makefile b/arch/mips/mti-malta/Makefile
> index cef2db8..26284fc 100644
> --- a/arch/mips/mti-malta/Makefile
> +++ b/arch/mips/mti-malta/Makefile
> @@ -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?
> +++ 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));
> + 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),
};
> +
> + /* 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
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] Support RTC on Malta
2008-10-30 12:05 ` [PATCH] Support RTC on Malta Ralf Baechle
@ 2008-10-31 6:44 ` tiejun.chen
2008-11-26 1:19 ` tiejun.chen
1 sibling, 0 replies; 8+ messages in thread
From: tiejun.chen @ 2008-10-31 6:44 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips
Ralf Baechle wrote:
> On Thu, Oct 30, 2008 at 07:15:44PM +0800, Tiejun Chen wrote:
>
> Looks reasonable but I have a few comments:
>
>> diff --git a/arch/mips/mti-malta/Makefile b/arch/mips/mti-malta/Makefile
>> index cef2db8..26284fc 100644
>> --- a/arch/mips/mti-malta/Makefile
>> +++ b/arch/mips/mti-malta/Makefile
>> @@ -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.
>> +++ 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));
>> + 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.
> static struct platform_device rtc_device = {
> .name = "rtc_cmos",
> .id = -1,
> .resource = &malta_platform_rtc_resource,
> .num_resources = ARRAY_SIZE(malta_platform_rtc_resource),
> };
>
>> +
>> + /* 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
> Can you fix that?
>
> Ralf
>
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] Support RTC on Malta
2008-10-30 12:05 ` [PATCH] Support RTC on Malta Ralf Baechle
2008-10-31 6:44 ` tiejun.chen
@ 2008-11-26 1:19 ` tiejun.chen
1 sibling, 0 replies; 8+ messages in thread
From: tiejun.chen @ 2008-11-26 1:19 UTC (permalink / raw)
To: Ralf Baechle; +Cc: linux-mips
Ralf Baechle wrote:
> On Thu, Oct 30, 2008 at 07:15:44PM +0800, Tiejun Chen wrote:
>
> Looks reasonable but I have a few comments:
>
>> diff --git a/arch/mips/mti-malta/Makefile b/arch/mips/mti-malta/Makefile
>> index cef2db8..26284fc 100644
>> --- a/arch/mips/mti-malta/Makefile
>> +++ b/arch/mips/mti-malta/Makefile
>> @@ -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?
>
>> +++ 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));
>> + 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),
> };
>
>> +
>> + /* 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,
I already re-sended another patch, [PATCH v2] Support RTC on Malta.
Best Regards
Tiejun
> Ralf
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-04-14 18:36 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-30 11:15 [PATCH] Support RTC on Malta Tiejun Chen
2008-10-30 11:15 ` [PATCH] Reserve stack/heap area for RP program Tiejun Chen
2008-10-30 12:17 ` Ralf Baechle
2008-10-31 1:42 ` tiejun.chen
2008-11-03 11:18 ` tiejun.chen
2008-10-30 12:05 ` [PATCH] Support RTC on Malta Ralf Baechle
2008-10-31 6:44 ` tiejun.chen
2008-11-26 1:19 ` tiejun.chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox