aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-nspire
diff options
context:
space:
mode:
authorDaniel Tang <dt.tangr@gmail.com>2013-06-11 04:40:17 -0400
committerArnd Bergmann <arnd@arndb.de>2013-06-21 14:06:30 -0400
commit9851ca5774e693e2088a4b34ad456cfaadaf29a7 (patch)
treefcfbad2c06f5a4ee0181a34b62bbbe06d1c3195f /arch/arm/mach-nspire
parentd907849e0dbaeacb34e0a6a3b49ebeaf8c49355e (diff)
arm: Add Initial TI-Nspire support
This patch adds support for the TI-Nspire platform. Changes between v1 and v2: * Added GENERIC_IRQ_CHIP to platform Kconfig Signed-off-by: Daniel Tang <dt.tangr@gmail.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch/arm/mach-nspire')
-rw-r--r--arch/arm/mach-nspire/Kconfig16
-rw-r--r--arch/arm/mach-nspire/Makefile2
-rw-r--r--arch/arm/mach-nspire/Makefile.boot0
-rw-r--r--arch/arm/mach-nspire/clcd.c119
-rw-r--r--arch/arm/mach-nspire/clcd.h14
-rw-r--r--arch/arm/mach-nspire/mmio.h20
-rw-r--r--arch/arm/mach-nspire/nspire.c89
7 files changed, 260 insertions, 0 deletions
diff --git a/arch/arm/mach-nspire/Kconfig b/arch/arm/mach-nspire/Kconfig
new file mode 100644
index 000000000000..59d8f0a70919
--- /dev/null
+++ b/arch/arm/mach-nspire/Kconfig
@@ -0,0 +1,16 @@
1config ARCH_NSPIRE
2 bool "TI-NSPIRE based"
3 depends on ARCH_MULTI_V4_V5
4 depends on MMU
5 select CPU_ARM926T
6 select COMMON_CLK
7 select GENERIC_CLOCKEVENTS
8 select GENERIC_IRQ_CHIP
9 select SPARSE_IRQ
10 select ARM_AMBA
11 select ARM_VIC
12 select ARM_TIMER_SP804
13 select USE_OF
14 select CLKSRC_OF
15 help
16 This enables support for systems using the TI-NSPIRE CPU
diff --git a/arch/arm/mach-nspire/Makefile b/arch/arm/mach-nspire/Makefile
new file mode 100644
index 000000000000..1bec256eba07
--- /dev/null
+++ b/arch/arm/mach-nspire/Makefile
@@ -0,0 +1,2 @@
1obj-y += nspire.o
2obj-y += clcd.o
diff --git a/arch/arm/mach-nspire/Makefile.boot b/arch/arm/mach-nspire/Makefile.boot
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/arch/arm/mach-nspire/Makefile.boot
diff --git a/arch/arm/mach-nspire/clcd.c b/arch/arm/mach-nspire/clcd.c
new file mode 100644
index 000000000000..abea12617b17
--- /dev/null
+++ b/arch/arm/mach-nspire/clcd.c
@@ -0,0 +1,119 @@
1/*
2 * linux/arch/arm/mach-nspire/clcd.c
3 *
4 * Copyright (C) 2013 Daniel Tang <tangrs@tangrs.id.au>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2, as
8 * published by the Free Software Foundation.
9 *
10 */
11
12#include <linux/init.h>
13#include <linux/of.h>
14#include <linux/amba/bus.h>
15#include <linux/amba/clcd.h>
16#include <linux/dma-mapping.h>
17
18static struct clcd_panel nspire_cx_lcd_panel = {
19 .mode = {
20 .name = "Color LCD",
21 .refresh = 60,
22 .xres = 320,
23 .yres = 240,
24 .sync = 0,
25 .vmode = FB_VMODE_NONINTERLACED,
26 .pixclock = 1,
27 .hsync_len = 6,
28 .vsync_len = 1,
29 .right_margin = 50,
30 .left_margin = 38,
31 .lower_margin = 3,
32 .upper_margin = 17,
33 },
34 .width = 65, /* ~6.50 cm */
35 .height = 49, /* ~4.87 cm */
36 .tim2 = TIM2_IPC,
37 .cntl = CNTL_LCDTFT | CNTL_LCDVCOMP(1),
38 .bpp = 16,
39 .caps = CLCD_CAP_565,
40};
41
42static struct clcd_panel nspire_classic_lcd_panel = {
43 .mode = {
44 .name = "Grayscale LCD",
45 .refresh = 60,
46 .xres = 320,
47 .yres = 240,
48 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
49 .vmode = FB_VMODE_NONINTERLACED,
50 .pixclock = 1,
51 .hsync_len = 6,
52 .vsync_len = 1,
53 .right_margin = 6,
54 .left_margin = 6,
55 },
56 .width = 71, /* 7.11cm */
57 .height = 53, /* 5.33cm */
58 .tim2 = 0x80007d0,
59 .cntl = CNTL_LCDMONO8,
60 .bpp = 8,
61 .grayscale = 1,
62 .caps = CLCD_CAP_5551,
63};
64
65int nspire_clcd_setup(struct clcd_fb *fb)
66{
67 struct clcd_panel *panel;
68 size_t panel_size;
69 const char *type;
70 dma_addr_t dma;
71 int err;
72
73 BUG_ON(!fb->dev->dev.of_node);
74
75 err = of_property_read_string(fb->dev->dev.of_node, "lcd-type", &type);
76 if (err) {
77 pr_err("CLCD: Could not find lcd-type property\n");
78 return err;
79 }
80
81 if (!strcmp(type, "cx")) {
82 panel = &nspire_cx_lcd_panel;
83 } else if (!strcmp(type, "classic")) {
84 panel = &nspire_classic_lcd_panel;
85 } else {
86 pr_err("CLCD: Unknown lcd-type %s\n", type);
87 return -EINVAL;
88 }
89
90 panel_size = ((panel->mode.xres * panel->mode.yres) * panel->bpp) / 8;
91 panel_size = ALIGN(panel_size, PAGE_SIZE);
92
93 fb->fb.screen_base = dma_alloc_writecombine(&fb->dev->dev,
94 panel_size, &dma, GFP_KERNEL);
95
96 if (!fb->fb.screen_base) {
97 pr_err("CLCD: unable to map framebuffer\n");
98 return -ENOMEM;
99 }
100
101 fb->fb.fix.smem_start = dma;
102 fb->fb.fix.smem_len = panel_size;
103 fb->panel = panel;
104
105 return 0;
106}
107
108int nspire_clcd_mmap(struct clcd_fb *fb, struct vm_area_struct *vma)
109{
110 return dma_mmap_writecombine(&fb->dev->dev, vma,
111 fb->fb.screen_base, fb->fb.fix.smem_start,
112 fb->fb.fix.smem_len);
113}
114
115void nspire_clcd_remove(struct clcd_fb *fb)
116{
117 dma_free_writecombine(&fb->dev->dev, fb->fb.fix.smem_len,
118 fb->fb.screen_base, fb->fb.fix.smem_start);
119}
diff --git a/arch/arm/mach-nspire/clcd.h b/arch/arm/mach-nspire/clcd.h
new file mode 100644
index 000000000000..8c33d2c18371
--- /dev/null
+++ b/arch/arm/mach-nspire/clcd.h
@@ -0,0 +1,14 @@
1/*
2 * linux/arch/arm/mach-nspire/clcd.h
3 *
4 * Copyright (C) 2013 Daniel Tang <tangrs@tangrs.id.au>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2, as
8 * published by the Free Software Foundation.
9 *
10 */
11
12int nspire_clcd_setup(struct clcd_fb *fb);
13int nspire_clcd_mmap(struct clcd_fb *fb, struct vm_area_struct *vma);
14void nspire_clcd_remove(struct clcd_fb *fb);
diff --git a/arch/arm/mach-nspire/mmio.h b/arch/arm/mach-nspire/mmio.h
new file mode 100644
index 000000000000..8813471af4cf
--- /dev/null
+++ b/arch/arm/mach-nspire/mmio.h
@@ -0,0 +1,20 @@
1/*
2 * linux/arch/arm/mach-nspire/mmio.h
3 *
4 * Copyright (C) 2013 Daniel Tang <tangrs@tangrs.id.au>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2, as
8 * published by the Free Software Foundation.
9 *
10 */
11
12#define NSPIRE_MISC_PHYS_BASE 0x900A0000
13#define NSPIRE_MISC_HWRESET 0x08
14
15#define NSPIRE_PWR_PHYS_BASE 0x900B0000
16#define NSPIRE_PWR_VIRT_BASE 0xFEEB0000
17#define NSPIRE_PWR_BUS_DISABLE1 0x18
18#define NSPIRE_PWR_BUS_DISABLE2 0x20
19
20#define NSPIRE_LCD_PHYS_BASE 0xC0000000
diff --git a/arch/arm/mach-nspire/nspire.c b/arch/arm/mach-nspire/nspire.c
new file mode 100644
index 000000000000..99e26092a9f7
--- /dev/null
+++ b/arch/arm/mach-nspire/nspire.c
@@ -0,0 +1,89 @@
1/*
2 * linux/arch/arm/mach-nspire/nspire.c
3 *
4 * Copyright (C) 2013 Daniel Tang <tangrs@tangrs.id.au>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2, as
8 * published by the Free Software Foundation.
9 *
10 */
11#include <linux/init.h>
12#include <linux/of_irq.h>
13#include <linux/of_address.h>
14#include <linux/of_platform.h>
15#include <linux/irqchip.h>
16#include <linux/irqchip/arm-vic.h>
17#include <linux/clk-provider.h>
18#include <linux/clkdev.h>
19#include <linux/amba/bus.h>
20#include <linux/amba/clcd.h>
21#include <linux/clocksource.h>
22
23#include <asm/mach/arch.h>
24#include <asm/mach-types.h>
25#include <asm/mach/map.h>
26
27#include <asm/hardware/timer-sp.h>
28
29#include "mmio.h"
30#include "clcd.h"
31
32static const char *nspire_dt_match[] __initconst = {
33 "ti,nspire",
34 "ti,nspire-cx",
35 "ti,nspire-tp",
36 "ti,nspire-clp",
37 NULL,
38};
39
40static void __init nspire_map_io(void)
41{
42 debug_ll_io_init();
43}
44
45static struct clcd_board nspire_clcd_data = {
46 .name = "LCD",
47 .caps = CLCD_CAP_5551 | CLCD_CAP_565,
48 .check = clcdfb_check,
49 .decode = clcdfb_decode,
50 .setup = nspire_clcd_setup,
51 .mmap = nspire_clcd_mmap,
52 .remove = nspire_clcd_remove,
53};
54
55
56static struct of_dev_auxdata nspire_auxdata[] __initdata = {
57 OF_DEV_AUXDATA("arm,pl111", NSPIRE_LCD_PHYS_BASE,
58 NULL, &nspire_clcd_data),
59 { }
60};
61
62static void __init nspire_init(void)
63{
64 of_platform_populate(NULL, of_default_bus_match_table,
65 nspire_auxdata, NULL);
66}
67
68static void __init nspire_init_time(void)
69{
70 of_clk_init(NULL);
71 clocksource_of_init();
72}
73
74static void nspire_restart(char mode, const char *cmd)
75{
76 void __iomem *base = ioremap(NSPIRE_MISC_PHYS_BASE, SZ_4K);
77 if (!base)
78 return;
79
80 writel(2, base + NSPIRE_MISC_HWRESET);
81}
82
83DT_MACHINE_START(NSPIRE, "TI-NSPIRE")
84 .dt_compat = nspire_dt_match,
85 .map_io = nspire_map_io,
86 .init_time = nspire_init_time,
87 .init_machine = nspire_init,
88 .restart = nspire_restart,
89MACHINE_END