Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: m-labs/linux-milkymist
base: 989f405
...
head fork: m-labs/linux-milkymist
compare: 9382ce7
  • 3 commits
  • 15 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jul 26, 2011
Michael Walle mwalle lm32: remove debug output in milkymistfb b54aa50
Michael Walle mwalle lm32: refactor lm32 architecture
Split setup code into generic and platform dependent code.
d256a10
Michael Walle mwalle lm32: simplify architecture setup
Move memory stuff into mm/init.c. Remove early_init(), almost everything
can be done in setup_arch(). Clear BSS in head.S.
9382ce7
1  arch/lm32/Makefile
View
@@ -39,6 +39,7 @@ OBJCOPYFLAGS :=-O binary -R .note -R .comment -S
head-y := arch/lm32/kernel/head.o arch/lm32/kernel/init_task.o
core-y += arch/lm32/
+core-y += arch/lm32/platforms/
libs-y += arch/lm32/lib/
boot := arch/lm32/boot
9 arch/lm32/include/asm/time.h
View
@@ -0,0 +1,9 @@
+#ifndef _ASM_LM32_TIME_H
+#define _ASM_LM32_TIME_H
+
+/*
+ * board specific routines required by time_init().
+ */
+extern void plat_time_init(void);
+
+#endif /* _ASM_TIME_H */
1  arch/lm32/kernel/Makefile
View
@@ -9,6 +9,5 @@ obj-y := \
flat.o sys_call_table.o cpuinfo.o prom.o \
platform.o
-obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
obj-$(CONFIG_MODULES) += module.o
32 arch/lm32/kernel/head.S
View
@@ -16,5 +16,35 @@ ENTRY(_start)
/* terminate frame pointer */
mvi fp, 0
- calli machine_early_init
+ /* clear bss */
+ mvhi r10, hi(__bss_start)
+ ori r10, r10, lo(__bss_start)
+ mvhi r11, hi(__bss_stop)
+ ori r11, r11, lo(__bss_stop)
+1:
+ be r10, r11, 2f
+ sw (r10+0), r0
+ addi r10, r10, 4
+ bi 1b
+2:
+
+ /*
+ * XXX: this will go away, if we have proper fdt support.
+ * Then, command line and initrd parameters are passed within the fdt
+ * blob
+ */
+ /* save cmdline pointer */
+ mvhi r10, hi(__cmdline)
+ ori r10, r10, lo(__cmdline)
+ sw (r10+0), r1
+
+ /* save initrd start and end pointer */
+ mvhi r10, hi(initrd_start)
+ ori r10, r10, lo(initrd_start)
+ sw (r10+0), r2
+
+ mvhi r10, hi(initrd_end)
+ ori r10, r10, lo(initrd_end)
+ sw (r10+0), r3
+
bi start_kernel
12 arch/lm32/kernel/prom.c
View
@@ -11,11 +11,17 @@
#include <linux/bootmem.h>
#include <linux/initrd.h>
#include <linux/memblock.h>
-#include <asm/setup.h>
+#include <asm/page.h>
void __init early_init_dt_add_memory_arch(u64 base, u64 size)
{
- memblock_add(base, size);
+ if (!memory_end) {
+ memory_start = base;
+ memory_end = base + size;
+ } else {
+ printk(KERN_CRIT "Only one memory bank is supported. "
+ "Ignoring memory at 0x%08llx\n", base);
+ }
}
void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
@@ -45,10 +51,8 @@ void __init early_init_devtree(void *params)
of_scan_flat_dt(early_init_dt_scan_chosen, cmd_line);
/* Scan memory nodes */
- memblock_init();
of_scan_flat_dt(early_init_dt_scan_root, NULL);
of_scan_flat_dt(early_init_dt_scan_memory, NULL);
- memblock_analyze();
}
void __init device_tree_init(void)
49 arch/lm32/kernel/setup.c
View
@@ -52,31 +52,16 @@
unsigned int kernel_mode = PT_MODE_KERNEL;
-char cmd_line[COMMAND_LINE_SIZE];
-
-extern void setup_early_printk(void);
+char __initdata cmd_line[COMMAND_LINE_SIZE];
/* from mm/init.c */
extern void bootmem_init(void);
unsigned int cpu_frequency;
+unsigned int __cmdline;
-void __init machine_early_init(char *cmdline, unsigned long p_initrd_start,
- unsigned long p_initrd_end)
+void __init __weak plat_setup_arch(void)
{
- /* clear bss section */
- memset(__bss_start, 0, __bss_stop - __bss_start);
-
- if (cmdline) {
- strlcpy(cmd_line, cmdline, COMMAND_LINE_SIZE);
- }
-
- initrd_start = p_initrd_start;
- initrd_end = p_initrd_end;
-
- early_init_devtree(__dtb_start);
- printk("initrd: %lx %lx\n", initrd_start, initrd_end);
- memblock_reserve(__pa(initrd_start), initrd_end - initrd_start);
}
void __init setup_arch(char **cmdline_p)
@@ -86,25 +71,27 @@ void __init setup_arch(char **cmdline_p)
*/
lm32_current_thread = (struct thread_info*)&init_thread_union;
- strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE);
+ if (__cmdline) {
+ strlcpy(cmd_line, (void*)__cmdline, COMMAND_LINE_SIZE);
+ strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE);
+ }
*cmdline_p = cmd_line;
-#ifdef CONFIG_DUMMY_CONSOLE
- conswitchp = &dummy_con;
-#endif
+ /* early commandline needed by memblock */
+ parse_early_param();
-#ifdef CONFIG_EARLY_PRINTK
- setup_early_printk();
-#endif
+ /* populate memory_start and memory_end, needed for bootmem_init() */
+ early_init_devtree(__dtb_start);
- /*
- * Init boot memory
- */
bootmem_init();
+
device_tree_init();
- /*
- * Get kmalloc into gear.
- */
paging_init();
+
+ plat_setup_arch();
+
+#ifdef CONFIG_DUMMY_CONSOLE
+ conswitchp = &dummy_con;
+#endif
}
162 arch/lm32/kernel/time.c
View
@@ -1,165 +1,7 @@
-/*
- * Copyright (C) 2011, Lars-Peter Clausen <lars@metafoo.de>
- * Clockevent and clocksource driver for the Milkymist sysctl timers
- *
- * 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.
- *
- * 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.,
- * 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
-#include <linux/interrupt.h>
#include <linux/kernel.h>
-
-#include <linux/clockchips.h>
-#include <linux/clocksource.h>
-#include <linux/timex.h>
-#include <linux/io.h>
-
-#include <asm/hw/interrupts.h>
-#include <asm/hw/sysctl.h>
-
-#define TIMER_CLOCKEVENT 0
-#define TIMER_CLOCKSOURCE 1
-
-static uint32_t milkymist_ticks_per_jiffy;
-
-static inline uint32_t milkymist_timer_get_counter(unsigned int timer)
-{
- return ioread32be(CSR_TIMER_COUNTER(timer));
-}
-
-static inline void milkymist_timer_set_counter(unsigned int timer, uint32_t value)
-{
- iowrite32be(value, CSR_TIMER_COUNTER(timer));
-}
-
-static inline uint32_t milkymist_timer_get_compare(unsigned int timer)
-{
- return ioread32be(CSR_TIMER_COMPARE(timer));
-}
-
-static inline void milkymist_timer_set_compare(unsigned int timer, uint32_t value)
-{
- iowrite32be(value, CSR_TIMER_COMPARE(timer));
-}
-
-static inline void milkymist_timer_disable(unsigned int timer)
-{
- iowrite32be(0, CSR_TIMER_CONTROL(timer));
-}
-
-static inline void milkymist_timer_enable(unsigned int timer, bool periodic)
-{
- uint32_t val = TIMER_ENABLE;
- if (periodic);
- val |= TIMER_AUTORESTART;
- iowrite32be(val, CSR_TIMER_CONTROL(timer));
-}
-
-cycles_t get_cycles(void)
-{
- return milkymist_timer_get_counter(TIMER_CLOCKSOURCE);
-}
-
-static cycle_t milkymist_clocksource_read(struct clocksource *cs)
-{
- return get_cycles();
-}
-
-static struct clocksource milkymist_clocksource = {
- .name = "milkymist-timer",
- .rating = 200,
- .read = milkymist_clocksource_read,
- .mask = CLOCKSOURCE_MASK(32),
- .flags = CLOCK_SOURCE_IS_CONTINUOUS,
-};
-
-static irqreturn_t milkymist_clockevent_irq(int irq, void *devid)
-{
- struct clock_event_device *cd = devid;
-
- if (cd->mode != CLOCK_EVT_MODE_PERIODIC)
- milkymist_timer_disable(TIMER_CLOCKEVENT);
-
- cd->event_handler(cd);
-
- return IRQ_HANDLED;
-}
-
-static void milkymist_clockevent_set_mode(enum clock_event_mode mode,
- struct clock_event_device *cd)
-{
- switch (mode) {
- case CLOCK_EVT_MODE_PERIODIC:
- milkymist_timer_disable(TIMER_CLOCKEVENT);
- milkymist_timer_set_counter(TIMER_CLOCKEVENT, 0);
- milkymist_timer_set_compare(TIMER_CLOCKEVENT, milkymist_ticks_per_jiffy);
- case CLOCK_EVT_MODE_RESUME:
- milkymist_timer_enable(TIMER_CLOCKEVENT, true);
- break;
- case CLOCK_EVT_MODE_ONESHOT:
- case CLOCK_EVT_MODE_SHUTDOWN:
- milkymist_timer_disable(TIMER_CLOCKEVENT);
- break;
- default:
- break;
- }
-}
-
-static int milkymist_clockevent_set_next(unsigned long evt,
- struct clock_event_device *cd)
-{
- milkymist_timer_set_counter(TIMER_CLOCKEVENT, 0);
- milkymist_timer_set_compare(TIMER_CLOCKEVENT, evt);
- milkymist_timer_enable(TIMER_CLOCKEVENT, false);
-
- return 0;
-}
-
-static struct clock_event_device milkymist_clockevent = {
- .name = "milkymist-timer",
- .features = CLOCK_EVT_FEAT_PERIODIC,
- .set_next_event = milkymist_clockevent_set_next,
- .set_mode = milkymist_clockevent_set_mode,
- .rating = 200,
- .irq = IRQ_TIMER0,
-};
-
-static struct irqaction timer_irqaction = {
- .handler = milkymist_clockevent_irq,
- .flags = IRQF_TIMER,
- .name = "milkymist-timerirq",
- .dev_id = &milkymist_clockevent,
-};
+#include <asm/time.h>
void __init time_init(void)
{
- int ret;
-
- milkymist_ticks_per_jiffy = DIV_ROUND_CLOSEST(CONFIG_CPU_CLOCK, HZ);
-
- clockevents_calc_mult_shift(&milkymist_clockevent, CONFIG_CPU_CLOCK, 5);
- milkymist_clockevent.min_delta_ns = clockevent_delta2ns(100, &milkymist_clockevent);
- milkymist_clockevent.max_delta_ns = clockevent_delta2ns(0xffff, &milkymist_clockevent);
- milkymist_clockevent.cpumask = cpumask_of(0);
-
- milkymist_timer_disable(TIMER_CLOCKSOURCE);
- milkymist_timer_set_compare(TIMER_CLOCKSOURCE, 0xffffffff);
- milkymist_timer_set_counter(TIMER_CLOCKSOURCE, 0);
- milkymist_timer_enable(TIMER_CLOCKSOURCE, true);
-
- clockevents_register_device(&milkymist_clockevent);
-
- ret = clocksource_register_hz(&milkymist_clocksource, CONFIG_CPU_CLOCK);
-
- if (ret)
- printk(KERN_ERR "Failed to register clocksource: %d\n", ret);
-
- setup_irq(IRQ_TIMER0, &timer_irqaction);
+ plat_time_init();
}
29 arch/lm32/mm/init.c
View
@@ -42,7 +42,7 @@
#include <linux/memblock.h>
#include <asm-generic/sections.h>
-#include <asm/setup.h>
+#include <asm/page.h>
unsigned long memory_start;
unsigned long memory_end;
@@ -53,25 +53,29 @@ void __init bootmem_init(void)
unsigned long bootmap_size;
unsigned long free_pfn, end_pfn, start_pfn;
- for_each_memblock(memory, reg) {
- memory_start = reg->base;
- memory_end = reg->base + reg->size;
- break;
- }
-
- if(((unsigned long)__pa(_end) < memory_start) || ((unsigned long)__pa(_end) > memory_end))
- printk("BUG: your kernel is not located in the ddr sdram");
-
init_mm.start_code = (unsigned long)_stext;
init_mm.end_code = (unsigned long)_etext;
init_mm.end_data = (unsigned long)_edata;
init_mm.brk = (unsigned long)_end;
+ memblock_init();
+ memblock_add(memory_start, memory_end);
+
+ if(((unsigned long)__pa(_end) < memory_start) || ((unsigned long)__pa(_end) > memory_end))
+ printk("BUG: your kernel is not located in the ddr sdram");
+
start_pfn = PFN_UP(memory_start);
free_pfn = PFN_UP(__pa((unsigned long)_end));
end_pfn = PFN_DOWN(memory_end);
- memblock_reserve(PFN_PHYS(start_pfn), PFN_PHYS(free_pfn - start_pfn));
+ //memblock_reserve(PFN_PHYS(start_pfn), PFN_PHYS(free_pfn - start_pfn));
+ memblock_reserve(__pa(_stext), _end - _stext);
+
+#ifdef CONFIG_BLK_DEV_INITRD
+ if (initrd_start && initrd_end && initrd_start < initrd_end) {
+ memblock_reserve(initrd_start, initrd_end - initrd_start);
+ }
+#endif
bootmap_size = init_bootmem(free_pfn, end_pfn);
memblock_reserve(PFN_PHYS(free_pfn), bootmap_size);
@@ -83,6 +87,9 @@ void __init bootmem_init(void)
memory_start += PAGE_OFFSET;
memory_end += PAGE_OFFSET;
+
+ memblock_analyze();
+ memblock_dump_all();
}
/*
2  arch/lm32/platforms/Makefile
View
@@ -0,0 +1,2 @@
+# arch/lm32/platforms/Makefile
+obj-$(CONFIG_PLAT_MILKYMIST) += milkymist/
4 arch/lm32/platforms/milkymist/Makefile
View
@@ -0,0 +1,4 @@
+# arch/lm32/platforms/milkymist/Makefile
+obj-y := time.o gpio.o setup.o
+
+obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
2  arch/lm32/kernel/early_printk.c → arch/lm32/platforms/milkymist/early_printk.c
View
@@ -69,7 +69,7 @@ static struct console early_console __initdata = {
static bool early_console_initialized __initdata;
-void __init setup_early_printk(void)
+void __init milkymist_setup_early_printk(void)
{
if (early_console_initialized)
return;
0  arch/lm32/kernel/gpio.c → arch/lm32/platforms/milkymist/gpio.c
View
File renamed without changes
11 arch/lm32/platforms/milkymist/setup.c
View
@@ -0,0 +1,11 @@
+#include <linux/kernel.h>
+
+extern void __init milkymist_setup_early_printk(void);
+
+void __init plat_setup_arch(void)
+{
+#ifdef CONFIG_EARLY_PRINTK
+ milkymist_setup_early_printk();
+#endif
+}
+
165 arch/lm32/platforms/milkymist/time.c
View
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2011, Lars-Peter Clausen <lars@metafoo.de>
+ * Clockevent and clocksource driver for the Milkymist sysctl timers
+ *
+ * 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.
+ *
+ * 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.,
+ * 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+
+#include <linux/clockchips.h>
+#include <linux/clocksource.h>
+#include <linux/timex.h>
+#include <linux/io.h>
+
+#include <asm/hw/interrupts.h>
+#include <asm/hw/sysctl.h>
+
+#define TIMER_CLOCKEVENT 0
+#define TIMER_CLOCKSOURCE 1
+
+static uint32_t milkymist_ticks_per_jiffy;
+
+static inline uint32_t milkymist_timer_get_counter(unsigned int timer)
+{
+ return ioread32be(CSR_TIMER_COUNTER(timer));
+}
+
+static inline void milkymist_timer_set_counter(unsigned int timer, uint32_t value)
+{
+ iowrite32be(value, CSR_TIMER_COUNTER(timer));
+}
+
+static inline uint32_t milkymist_timer_get_compare(unsigned int timer)
+{
+ return ioread32be(CSR_TIMER_COMPARE(timer));
+}
+
+static inline void milkymist_timer_set_compare(unsigned int timer, uint32_t value)
+{
+ iowrite32be(value, CSR_TIMER_COMPARE(timer));
+}
+
+static inline void milkymist_timer_disable(unsigned int timer)
+{
+ iowrite32be(0, CSR_TIMER_CONTROL(timer));
+}
+
+static inline void milkymist_timer_enable(unsigned int timer, bool periodic)
+{
+ uint32_t val = TIMER_ENABLE;
+ if (periodic);
+ val |= TIMER_AUTORESTART;
+ iowrite32be(val, CSR_TIMER_CONTROL(timer));
+}
+
+cycles_t get_cycles(void)
+{
+ return milkymist_timer_get_counter(TIMER_CLOCKSOURCE);
+}
+
+static cycle_t milkymist_clocksource_read(struct clocksource *cs)
+{
+ return get_cycles();
+}
+
+static struct clocksource milkymist_clocksource = {
+ .name = "milkymist-timer",
+ .rating = 200,
+ .read = milkymist_clocksource_read,
+ .mask = CLOCKSOURCE_MASK(32),
+ .flags = CLOCK_SOURCE_IS_CONTINUOUS,
+};
+
+static irqreturn_t milkymist_clockevent_irq(int irq, void *devid)
+{
+ struct clock_event_device *cd = devid;
+
+ if (cd->mode != CLOCK_EVT_MODE_PERIODIC)
+ milkymist_timer_disable(TIMER_CLOCKEVENT);
+
+ cd->event_handler(cd);
+
+ return IRQ_HANDLED;
+}
+
+static void milkymist_clockevent_set_mode(enum clock_event_mode mode,
+ struct clock_event_device *cd)
+{
+ switch (mode) {
+ case CLOCK_EVT_MODE_PERIODIC:
+ milkymist_timer_disable(TIMER_CLOCKEVENT);
+ milkymist_timer_set_counter(TIMER_CLOCKEVENT, 0);
+ milkymist_timer_set_compare(TIMER_CLOCKEVENT, milkymist_ticks_per_jiffy);
+ case CLOCK_EVT_MODE_RESUME:
+ milkymist_timer_enable(TIMER_CLOCKEVENT, true);
+ break;
+ case CLOCK_EVT_MODE_ONESHOT:
+ case CLOCK_EVT_MODE_SHUTDOWN:
+ milkymist_timer_disable(TIMER_CLOCKEVENT);
+ break;
+ default:
+ break;
+ }
+}
+
+static int milkymist_clockevent_set_next(unsigned long evt,
+ struct clock_event_device *cd)
+{
+ milkymist_timer_set_counter(TIMER_CLOCKEVENT, 0);
+ milkymist_timer_set_compare(TIMER_CLOCKEVENT, evt);
+ milkymist_timer_enable(TIMER_CLOCKEVENT, false);
+
+ return 0;
+}
+
+static struct clock_event_device milkymist_clockevent = {
+ .name = "milkymist-timer",
+ .features = CLOCK_EVT_FEAT_PERIODIC,
+ .set_next_event = milkymist_clockevent_set_next,
+ .set_mode = milkymist_clockevent_set_mode,
+ .rating = 200,
+ .irq = IRQ_TIMER0,
+};
+
+static struct irqaction timer_irqaction = {
+ .handler = milkymist_clockevent_irq,
+ .flags = IRQF_TIMER,
+ .name = "milkymist-timerirq",
+ .dev_id = &milkymist_clockevent,
+};
+
+void __init plat_time_init(void)
+{
+ int ret;
+
+ milkymist_ticks_per_jiffy = DIV_ROUND_CLOSEST(CONFIG_CPU_CLOCK, HZ);
+
+ clockevents_calc_mult_shift(&milkymist_clockevent, CONFIG_CPU_CLOCK, 5);
+ milkymist_clockevent.min_delta_ns = clockevent_delta2ns(100, &milkymist_clockevent);
+ milkymist_clockevent.max_delta_ns = clockevent_delta2ns(0xffff, &milkymist_clockevent);
+ milkymist_clockevent.cpumask = cpumask_of(0);
+
+ milkymist_timer_disable(TIMER_CLOCKSOURCE);
+ milkymist_timer_set_compare(TIMER_CLOCKSOURCE, 0xffffffff);
+ milkymist_timer_set_counter(TIMER_CLOCKSOURCE, 0);
+ milkymist_timer_enable(TIMER_CLOCKSOURCE, true);
+
+ clockevents_register_device(&milkymist_clockevent);
+
+ ret = clocksource_register_hz(&milkymist_clocksource, CONFIG_CPU_CLOCK);
+
+ if (ret)
+ printk(KERN_ERR "Failed to register clocksource: %d\n", ret);
+
+ setup_irq(IRQ_TIMER0, &timer_irqaction);
+}
2  drivers/video/milkymistfb.c
View
@@ -257,8 +257,6 @@ static int __devinit milkymistfb_probe(struct platform_device *ofdev)
struct resource res;
const unsigned int *vidmemsize;
- printk("%s:%d\n", __FILE__, __LINE__);
-
ret = of_address_to_resource(np, 0, &res);
if (ret) {
dev_err(&ofdev->dev, "invalid address\n");

No commit comments for this range

Something went wrong with that request. Please try again.