diff options
Diffstat (limited to 'arch/arm/mach-nomadik')
24 files changed, 1526 insertions, 0 deletions
diff --git a/arch/arm/mach-nomadik/Kconfig b/arch/arm/mach-nomadik/Kconfig new file mode 100644 index 000000000000..2a02b49c40f0 --- /dev/null +++ b/arch/arm/mach-nomadik/Kconfig | |||
@@ -0,0 +1,21 @@ | |||
1 | if ARCH_NOMADIK | ||
2 | |||
3 | menu "Nomadik boards" | ||
4 | |||
5 | config MACH_NOMADIK_8815NHK | ||
6 | bool "ST 8815 Nomadik Hardware Kit (evaluation board)" | ||
7 | select NOMADIK_8815 | ||
8 | |||
9 | endmenu | ||
10 | |||
11 | config NOMADIK_8815 | ||
12 | bool | ||
13 | |||
14 | |||
15 | config I2C_BITBANG_8815NHK | ||
16 | tristate "Driver for bit-bang busses found on the 8815 NHK" | ||
17 | depends on I2C && MACH_NOMADIK_8815NHK | ||
18 | select I2C_ALGOBIT | ||
19 | default y | ||
20 | |||
21 | endif | ||
diff --git a/arch/arm/mach-nomadik/Makefile b/arch/arm/mach-nomadik/Makefile new file mode 100644 index 000000000000..412040982a40 --- /dev/null +++ b/arch/arm/mach-nomadik/Makefile | |||
@@ -0,0 +1,19 @@ | |||
1 | # | ||
2 | # Makefile for the linux kernel. | ||
3 | # | ||
4 | # Note! Dependencies are done automagically by 'make dep', which also | ||
5 | # removes any old dependencies. DON'T put your own dependencies here | ||
6 | # unless it's something special (ie not a .c file). | ||
7 | |||
8 | # Object file lists. | ||
9 | |||
10 | obj-y += clock.o timer.o gpio.o | ||
11 | |||
12 | # Cpu revision | ||
13 | obj-$(CONFIG_NOMADIK_8815) += cpu-8815.o | ||
14 | |||
15 | # Specific board support | ||
16 | obj-$(CONFIG_MACH_NOMADIK_8815NHK) += board-nhk8815.o | ||
17 | |||
18 | # Nomadik extra devices | ||
19 | obj-$(CONFIG_I2C_BITBANG_8815NHK) += i2c-8815nhk.o | ||
diff --git a/arch/arm/mach-nomadik/Makefile.boot b/arch/arm/mach-nomadik/Makefile.boot new file mode 100644 index 000000000000..c7e75acfe6c9 --- /dev/null +++ b/arch/arm/mach-nomadik/Makefile.boot | |||
@@ -0,0 +1,4 @@ | |||
1 | zreladdr-y := 0x00008000 | ||
2 | params_phys-y := 0x00000100 | ||
3 | initrd_phys-y := 0x00800000 | ||
4 | |||
diff --git a/arch/arm/mach-nomadik/board-nhk8815.c b/arch/arm/mach-nomadik/board-nhk8815.c new file mode 100644 index 000000000000..79bdea943eb4 --- /dev/null +++ b/arch/arm/mach-nomadik/board-nhk8815.c | |||
@@ -0,0 +1,111 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/mach-nomadik/board-8815nhk.c | ||
3 | * | ||
4 | * Copyright (C) STMicroelectronics | ||
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 | * NHK15 board specifc driver definition | ||
11 | */ | ||
12 | #include <linux/types.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/platform_device.h> | ||
16 | #include <linux/amba/bus.h> | ||
17 | #include <linux/interrupt.h> | ||
18 | #include <linux/gpio.h> | ||
19 | #include <asm/mach-types.h> | ||
20 | #include <asm/mach/arch.h> | ||
21 | #include <asm/mach/irq.h> | ||
22 | #include <mach/setup.h> | ||
23 | #include "clock.h" | ||
24 | |||
25 | #define __MEM_4K_RESOURCE(x) \ | ||
26 | .res = {.start = (x), .end = (x) + SZ_4K - 1, .flags = IORESOURCE_MEM} | ||
27 | |||
28 | static struct amba_device uart0_device = { | ||
29 | .dev = { .init_name = "uart0" }, | ||
30 | __MEM_4K_RESOURCE(NOMADIK_UART0_BASE), | ||
31 | .irq = {IRQ_UART0, NO_IRQ}, | ||
32 | }; | ||
33 | |||
34 | static struct amba_device uart1_device = { | ||
35 | .dev = { .init_name = "uart1" }, | ||
36 | __MEM_4K_RESOURCE(NOMADIK_UART1_BASE), | ||
37 | .irq = {IRQ_UART1, NO_IRQ}, | ||
38 | }; | ||
39 | |||
40 | static struct amba_device *amba_devs[] __initdata = { | ||
41 | &uart0_device, | ||
42 | &uart1_device, | ||
43 | }; | ||
44 | |||
45 | /* We have a fixed clock alone, by now */ | ||
46 | static struct clk nhk8815_clk_48 = { | ||
47 | .rate = 48*1000*1000, | ||
48 | }; | ||
49 | |||
50 | static struct resource nhk8815_eth_resources[] = { | ||
51 | { | ||
52 | .name = "smc91x-regs", | ||
53 | .start = 0x34000000 + 0x300, | ||
54 | .end = 0x34000000 + SZ_64K - 1, | ||
55 | .flags = IORESOURCE_MEM, | ||
56 | }, { | ||
57 | .start = NOMADIK_GPIO_TO_IRQ(115), | ||
58 | .end = NOMADIK_GPIO_TO_IRQ(115), | ||
59 | .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING, | ||
60 | } | ||
61 | }; | ||
62 | |||
63 | static struct platform_device nhk8815_eth_device = { | ||
64 | .name = "smc91x", | ||
65 | .resource = nhk8815_eth_resources, | ||
66 | .num_resources = ARRAY_SIZE(nhk8815_eth_resources), | ||
67 | }; | ||
68 | |||
69 | static int __init nhk8815_eth_init(void) | ||
70 | { | ||
71 | int gpio_nr = 115; /* hardwired in the board */ | ||
72 | int err; | ||
73 | |||
74 | err = gpio_request(gpio_nr, "eth_irq"); | ||
75 | if (!err) err = nmk_gpio_set_mode(gpio_nr, NMK_GPIO_ALT_GPIO); | ||
76 | if (!err) err = gpio_direction_input(gpio_nr); | ||
77 | if (err) | ||
78 | pr_err("Error %i in %s\n", err, __func__); | ||
79 | return err; | ||
80 | } | ||
81 | device_initcall(nhk8815_eth_init); | ||
82 | |||
83 | static struct platform_device *nhk8815_platform_devices[] __initdata = { | ||
84 | &nhk8815_eth_device, | ||
85 | /* will add more devices */ | ||
86 | }; | ||
87 | |||
88 | static void __init nhk8815_platform_init(void) | ||
89 | { | ||
90 | int i; | ||
91 | |||
92 | cpu8815_platform_init(); | ||
93 | platform_add_devices(nhk8815_platform_devices, | ||
94 | ARRAY_SIZE(nhk8815_platform_devices)); | ||
95 | |||
96 | for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { | ||
97 | nmdk_clk_create(&nhk8815_clk_48, amba_devs[i]->dev.init_name); | ||
98 | amba_device_register(amba_devs[i], &iomem_resource); | ||
99 | } | ||
100 | } | ||
101 | |||
102 | MACHINE_START(NOMADIK, "NHK8815") | ||
103 | /* Maintainer: ST MicroElectronics */ | ||
104 | .phys_io = NOMADIK_UART0_BASE, | ||
105 | .io_pg_offst = (IO_ADDRESS(NOMADIK_UART0_BASE) >> 18) & 0xfffc, | ||
106 | .boot_params = 0x100, | ||
107 | .map_io = cpu8815_map_io, | ||
108 | .init_irq = cpu8815_init_irq, | ||
109 | .timer = &nomadik_timer, | ||
110 | .init_machine = nhk8815_platform_init, | ||
111 | MACHINE_END | ||
diff --git a/arch/arm/mach-nomadik/clock.c b/arch/arm/mach-nomadik/clock.c new file mode 100644 index 000000000000..9f92502a0083 --- /dev/null +++ b/arch/arm/mach-nomadik/clock.c | |||
@@ -0,0 +1,45 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/mach-nomadik/clock.c | ||
3 | * | ||
4 | * Copyright (C) 2009 Alessandro Rubini | ||
5 | */ | ||
6 | #include <linux/kernel.h> | ||
7 | #include <linux/module.h> | ||
8 | #include <linux/errno.h> | ||
9 | #include <linux/clk.h> | ||
10 | #include <asm/clkdev.h> | ||
11 | #include "clock.h" | ||
12 | |||
13 | /* | ||
14 | * The nomadik board uses generic clocks, but the serial pl011 file | ||
15 | * calls clk_enable(), clk_disable(), clk_get_rate(), so we provide them | ||
16 | */ | ||
17 | unsigned long clk_get_rate(struct clk *clk) | ||
18 | { | ||
19 | return clk->rate; | ||
20 | } | ||
21 | EXPORT_SYMBOL(clk_get_rate); | ||
22 | |||
23 | /* enable and disable do nothing */ | ||
24 | int clk_enable(struct clk *clk) | ||
25 | { | ||
26 | return 0; | ||
27 | } | ||
28 | EXPORT_SYMBOL(clk_enable); | ||
29 | |||
30 | void clk_disable(struct clk *clk) | ||
31 | { | ||
32 | } | ||
33 | EXPORT_SYMBOL(clk_disable); | ||
34 | |||
35 | /* Create a clock structure with the given name */ | ||
36 | int nmdk_clk_create(struct clk *clk, const char *dev_id) | ||
37 | { | ||
38 | struct clk_lookup *clkdev; | ||
39 | |||
40 | clkdev = clkdev_alloc(clk, NULL, dev_id); | ||
41 | if (!clkdev) | ||
42 | return -ENOMEM; | ||
43 | clkdev_add(clkdev); | ||
44 | return 0; | ||
45 | } | ||
diff --git a/arch/arm/mach-nomadik/clock.h b/arch/arm/mach-nomadik/clock.h new file mode 100644 index 000000000000..235faec7f627 --- /dev/null +++ b/arch/arm/mach-nomadik/clock.h | |||
@@ -0,0 +1,14 @@ | |||
1 | |||
2 | /* | ||
3 | * linux/arch/arm/mach-nomadik/clock.h | ||
4 | * | ||
5 | * Copyright (C) 2009 Alessandro Rubini | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | struct clk { | ||
12 | unsigned long rate; | ||
13 | }; | ||
14 | extern int nmdk_clk_create(struct clk *clk, const char *dev_id); | ||
diff --git a/arch/arm/mach-nomadik/cpu-8815.c b/arch/arm/mach-nomadik/cpu-8815.c new file mode 100644 index 000000000000..f93c59634191 --- /dev/null +++ b/arch/arm/mach-nomadik/cpu-8815.c | |||
@@ -0,0 +1,139 @@ | |||
1 | /* | ||
2 | * Copyright STMicroelectronics, 2007. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
17 | */ | ||
18 | |||
19 | #include <linux/types.h> | ||
20 | #include <linux/init.h> | ||
21 | #include <linux/device.h> | ||
22 | #include <linux/amba/bus.h> | ||
23 | #include <linux/gpio.h> | ||
24 | |||
25 | #include <mach/hardware.h> | ||
26 | #include <mach/irqs.h> | ||
27 | #include <asm/mach/map.h> | ||
28 | #include <asm/hardware/vic.h> | ||
29 | |||
30 | #include <asm/cacheflush.h> | ||
31 | #include <asm/hardware/cache-l2x0.h> | ||
32 | |||
33 | /* The 8815 has 4 GPIO blocks, let's register them immediately */ | ||
34 | static struct nmk_gpio_platform_data cpu8815_gpio[] = { | ||
35 | { | ||
36 | .name = "GPIO-0-31", | ||
37 | .first_gpio = 0, | ||
38 | .first_irq = NOMADIK_GPIO_TO_IRQ(0), | ||
39 | .parent_irq = IRQ_GPIO0, | ||
40 | }, { | ||
41 | .name = "GPIO-32-63", | ||
42 | .first_gpio = 32, | ||
43 | .first_irq = NOMADIK_GPIO_TO_IRQ(32), | ||
44 | .parent_irq = IRQ_GPIO1, | ||
45 | }, { | ||
46 | .name = "GPIO-64-95", | ||
47 | .first_gpio = 64, | ||
48 | .first_irq = NOMADIK_GPIO_TO_IRQ(64), | ||
49 | .parent_irq = IRQ_GPIO2, | ||
50 | }, { | ||
51 | .name = "GPIO-96-127", /* 124..127 not routed to pin */ | ||
52 | .first_gpio = 96, | ||
53 | .first_irq = NOMADIK_GPIO_TO_IRQ(96), | ||
54 | .parent_irq = IRQ_GPIO3, | ||
55 | } | ||
56 | }; | ||
57 | |||
58 | #define __MEM_4K_RESOURCE(x) \ | ||
59 | .res = {.start = (x), .end = (x) + SZ_4K - 1, .flags = IORESOURCE_MEM} | ||
60 | |||
61 | static struct amba_device cpu8815_amba_gpio[] = { | ||
62 | { | ||
63 | .dev = { | ||
64 | .init_name = "gpio0", | ||
65 | .platform_data = cpu8815_gpio + 0, | ||
66 | }, | ||
67 | __MEM_4K_RESOURCE(NOMADIK_GPIO0_BASE), | ||
68 | }, { | ||
69 | .dev = { | ||
70 | .init_name = "gpio1", | ||
71 | .platform_data = cpu8815_gpio + 1, | ||
72 | }, | ||
73 | __MEM_4K_RESOURCE(NOMADIK_GPIO1_BASE), | ||
74 | }, { | ||
75 | .dev = { | ||
76 | .init_name = "gpio2", | ||
77 | .platform_data = cpu8815_gpio + 2, | ||
78 | }, | ||
79 | __MEM_4K_RESOURCE(NOMADIK_GPIO2_BASE), | ||
80 | }, { | ||
81 | .dev = { | ||
82 | .init_name = "gpio3", | ||
83 | .platform_data = cpu8815_gpio + 3, | ||
84 | }, | ||
85 | __MEM_4K_RESOURCE(NOMADIK_GPIO3_BASE), | ||
86 | }, | ||
87 | }; | ||
88 | |||
89 | static struct amba_device *amba_devs[] __initdata = { | ||
90 | cpu8815_amba_gpio + 0, | ||
91 | cpu8815_amba_gpio + 1, | ||
92 | cpu8815_amba_gpio + 2, | ||
93 | cpu8815_amba_gpio + 3, | ||
94 | }; | ||
95 | |||
96 | static int __init cpu8815_init(void) | ||
97 | { | ||
98 | int i; | ||
99 | |||
100 | for (i = 0; i < ARRAY_SIZE(amba_devs); i++) | ||
101 | amba_device_register(amba_devs[i], &iomem_resource); | ||
102 | return 0; | ||
103 | } | ||
104 | arch_initcall(cpu8815_init); | ||
105 | |||
106 | /* All SoC devices live in the same area (see hardware.h) */ | ||
107 | static struct map_desc nomadik_io_desc[] __initdata = { | ||
108 | { | ||
109 | .virtual = NOMADIK_IO_VIRTUAL, | ||
110 | .pfn = __phys_to_pfn(NOMADIK_IO_PHYSICAL), | ||
111 | .length = NOMADIK_IO_SIZE, | ||
112 | .type = MT_DEVICE, | ||
113 | } | ||
114 | /* static ram and secured ram may be added later */ | ||
115 | }; | ||
116 | |||
117 | void __init cpu8815_map_io(void) | ||
118 | { | ||
119 | iotable_init(nomadik_io_desc, ARRAY_SIZE(nomadik_io_desc)); | ||
120 | } | ||
121 | |||
122 | void __init cpu8815_init_irq(void) | ||
123 | { | ||
124 | /* This modified VIC cell has two register blocks, at 0 and 0x20 */ | ||
125 | vic_init(io_p2v(NOMADIK_IC_BASE + 0x00), IRQ_VIC_START + 0, ~0, 0); | ||
126 | vic_init(io_p2v(NOMADIK_IC_BASE + 0x20), IRQ_VIC_START + 32, ~0, 0); | ||
127 | } | ||
128 | |||
129 | /* | ||
130 | * This function is called from the board init ("init_machine"). | ||
131 | */ | ||
132 | void __init cpu8815_platform_init(void) | ||
133 | { | ||
134 | #ifdef CONFIG_CACHE_L2X0 | ||
135 | /* At full speed latency must be >=2, so 0x249 in low bits */ | ||
136 | l2x0_init(io_p2v(NOMADIK_L2CC_BASE), 0x00730249, 0xfe000fff); | ||
137 | #endif | ||
138 | return; | ||
139 | } | ||
diff --git a/arch/arm/mach-nomadik/gpio.c b/arch/arm/mach-nomadik/gpio.c new file mode 100644 index 000000000000..9a09b2791e03 --- /dev/null +++ b/arch/arm/mach-nomadik/gpio.c | |||
@@ -0,0 +1,396 @@ | |||
1 | /* | ||
2 | * Generic GPIO driver for logic cells found in the Nomadik SoC | ||
3 | * | ||
4 | * Copyright (C) 2008,2009 STMicroelectronics | ||
5 | * Copyright (C) 2009 Alessandro Rubini <rubini@unipv.it> | ||
6 | * Rewritten based on work by Prafulla WADASKAR <prafulla.wadaskar@st.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/init.h> | ||
15 | #include <linux/device.h> | ||
16 | #include <linux/amba/bus.h> | ||
17 | #include <linux/io.h> | ||
18 | #include <linux/gpio.h> | ||
19 | #include <linux/spinlock.h> | ||
20 | #include <linux/interrupt.h> | ||
21 | #include <linux/irq.h> | ||
22 | |||
23 | #include <mach/hardware.h> | ||
24 | #include <mach/gpio.h> | ||
25 | |||
26 | /* | ||
27 | * The GPIO module in the Nomadik family of Systems-on-Chip is an | ||
28 | * AMBA device, managing 32 pins and alternate functions. The logic block | ||
29 | * is currently only used in the Nomadik. | ||
30 | * | ||
31 | * Symbols in this file are called "nmk_gpio" for "nomadik gpio" | ||
32 | */ | ||
33 | |||
34 | #define NMK_GPIO_PER_CHIP 32 | ||
35 | struct nmk_gpio_chip { | ||
36 | struct gpio_chip chip; | ||
37 | void __iomem *addr; | ||
38 | unsigned int parent_irq; | ||
39 | spinlock_t *lock; | ||
40 | /* Keep track of configured edges */ | ||
41 | u32 edge_rising; | ||
42 | u32 edge_falling; | ||
43 | }; | ||
44 | |||
45 | /* Mode functions */ | ||
46 | int nmk_gpio_set_mode(int gpio, int gpio_mode) | ||
47 | { | ||
48 | struct nmk_gpio_chip *nmk_chip; | ||
49 | unsigned long flags; | ||
50 | u32 afunc, bfunc, bit; | ||
51 | |||
52 | nmk_chip = get_irq_chip_data(NOMADIK_GPIO_TO_IRQ(gpio)); | ||
53 | if (!nmk_chip) | ||
54 | return -EINVAL; | ||
55 | |||
56 | bit = 1 << (gpio - nmk_chip->chip.base); | ||
57 | |||
58 | spin_lock_irqsave(&nmk_chip->lock, flags); | ||
59 | afunc = readl(nmk_chip->addr + NMK_GPIO_AFSLA) & ~bit; | ||
60 | bfunc = readl(nmk_chip->addr + NMK_GPIO_AFSLB) & ~bit; | ||
61 | if (gpio_mode & NMK_GPIO_ALT_A) | ||
62 | afunc |= bit; | ||
63 | if (gpio_mode & NMK_GPIO_ALT_B) | ||
64 | bfunc |= bit; | ||
65 | writel(afunc, nmk_chip->addr + NMK_GPIO_AFSLA); | ||
66 | writel(bfunc, nmk_chip->addr + NMK_GPIO_AFSLB); | ||
67 | spin_unlock_irqrestore(&nmk_chip->lock, flags); | ||
68 | |||
69 | return 0; | ||
70 | } | ||
71 | EXPORT_SYMBOL(nmk_gpio_set_mode); | ||
72 | |||
73 | int nmk_gpio_get_mode(int gpio) | ||
74 | { | ||
75 | struct nmk_gpio_chip *nmk_chip; | ||
76 | u32 afunc, bfunc, bit; | ||
77 | |||
78 | nmk_chip = get_irq_chip_data(NOMADIK_GPIO_TO_IRQ(gpio)); | ||
79 | if (!nmk_chip) | ||
80 | return -EINVAL; | ||
81 | |||
82 | bit = 1 << (gpio - nmk_chip->chip.base); | ||
83 | |||
84 | afunc = readl(nmk_chip->addr + NMK_GPIO_AFSLA) & bit; | ||
85 | bfunc = readl(nmk_chip->addr + NMK_GPIO_AFSLB) & bit; | ||
86 | |||
87 | return (afunc ? NMK_GPIO_ALT_A : 0) | (bfunc ? NMK_GPIO_ALT_B : 0); | ||
88 | } | ||
89 | EXPORT_SYMBOL(nmk_gpio_get_mode); | ||
90 | |||
91 | |||
92 | /* IRQ functions */ | ||
93 | static inline int nmk_gpio_get_bitmask(int gpio) | ||
94 | { | ||
95 | return 1 << (gpio % 32); | ||
96 | } | ||
97 | |||
98 | static void nmk_gpio_irq_ack(unsigned int irq) | ||
99 | { | ||
100 | int gpio; | ||
101 | struct nmk_gpio_chip *nmk_chip; | ||
102 | |||
103 | gpio = NOMADIK_IRQ_TO_GPIO(irq); | ||
104 | nmk_chip = get_irq_chip_data(irq); | ||
105 | if (!nmk_chip) | ||
106 | return; | ||
107 | writel(nmk_gpio_get_bitmask(gpio), nmk_chip->addr + NMK_GPIO_IC); | ||
108 | } | ||
109 | |||
110 | static void nmk_gpio_irq_mask(unsigned int irq) | ||
111 | { | ||
112 | int gpio; | ||
113 | struct nmk_gpio_chip *nmk_chip; | ||
114 | unsigned long flags; | ||
115 | u32 bitmask, reg; | ||
116 | |||
117 | gpio = NOMADIK_IRQ_TO_GPIO(irq); | ||
118 | nmk_chip = get_irq_chip_data(irq); | ||
119 | bitmask = nmk_gpio_get_bitmask(gpio); | ||
120 | if (!nmk_chip) | ||
121 | return; | ||
122 | |||
123 | /* we must individually clear the two edges */ | ||
124 | spin_lock_irqsave(&nmk_chip->lock, flags); | ||
125 | if (nmk_chip->edge_rising & bitmask) { | ||
126 | reg = readl(nmk_chip->addr + NMK_GPIO_RWIMSC); | ||
127 | reg &= ~bitmask; | ||
128 | writel(reg, nmk_chip->addr + NMK_GPIO_RWIMSC); | ||
129 | } | ||
130 | if (nmk_chip->edge_falling & bitmask) { | ||
131 | reg = readl(nmk_chip->addr + NMK_GPIO_FWIMSC); | ||
132 | reg &= ~bitmask; | ||
133 | writel(reg, nmk_chip->addr + NMK_GPIO_FWIMSC); | ||
134 | } | ||
135 | spin_unlock_irqrestore(&nmk_chip->lock, flags); | ||
136 | }; | ||
137 | |||
138 | static void nmk_gpio_irq_unmask(unsigned int irq) | ||
139 | { | ||
140 | int gpio; | ||
141 | struct nmk_gpio_chip *nmk_chip; | ||
142 | unsigned long flags; | ||
143 | u32 bitmask, reg; | ||
144 | |||
145 | gpio = NOMADIK_IRQ_TO_GPIO(irq); | ||
146 | nmk_chip = get_irq_chip_data(irq); | ||
147 | bitmask = nmk_gpio_get_bitmask(gpio); | ||
148 | if (!nmk_chip) | ||
149 | return; | ||
150 | |||
151 | /* we must individually set the two edges */ | ||
152 | spin_lock_irqsave(&nmk_chip->lock, flags); | ||
153 | if (nmk_chip->edge_rising & bitmask) { | ||
154 | reg = readl(nmk_chip->addr + NMK_GPIO_RWIMSC); | ||
155 | reg |= bitmask; | ||
156 | writel(reg, nmk_chip->addr + NMK_GPIO_RWIMSC); | ||
157 | } | ||
158 | if (nmk_chip->edge_falling & bitmask) { | ||
159 | reg = readl(nmk_chip->addr + NMK_GPIO_FWIMSC); | ||
160 | reg |= bitmask; | ||
161 | writel(reg, nmk_chip->addr + NMK_GPIO_FWIMSC); | ||
162 | } | ||
163 | spin_unlock_irqrestore(&nmk_chip->lock, flags); | ||
164 | } | ||
165 | |||
166 | static int nmk_gpio_irq_set_type(unsigned int irq, unsigned int type) | ||
167 | { | ||
168 | int gpio; | ||
169 | struct nmk_gpio_chip *nmk_chip; | ||
170 | unsigned long flags; | ||
171 | u32 bitmask; | ||
172 | |||
173 | gpio = NOMADIK_IRQ_TO_GPIO(irq); | ||
174 | nmk_chip = get_irq_chip_data(irq); | ||
175 | bitmask = nmk_gpio_get_bitmask(gpio); | ||
176 | if (!nmk_chip) | ||
177 | return -EINVAL; | ||
178 | |||
179 | if (type & IRQ_TYPE_LEVEL_HIGH) | ||
180 | return -EINVAL; | ||
181 | if (type & IRQ_TYPE_LEVEL_LOW) | ||
182 | return -EINVAL; | ||
183 | |||
184 | spin_lock_irqsave(&nmk_chip->lock, flags); | ||
185 | |||
186 | nmk_chip->edge_rising &= ~bitmask; | ||
187 | if (type & IRQ_TYPE_EDGE_RISING) | ||
188 | nmk_chip->edge_rising |= bitmask; | ||
189 | writel(nmk_chip->edge_rising, nmk_chip->addr + NMK_GPIO_RIMSC); | ||
190 | |||
191 | nmk_chip->edge_falling &= ~bitmask; | ||
192 | if (type & IRQ_TYPE_EDGE_FALLING) | ||
193 | nmk_chip->edge_falling |= bitmask; | ||
194 | writel(nmk_chip->edge_falling, nmk_chip->addr + NMK_GPIO_FIMSC); | ||
195 | |||
196 | spin_unlock_irqrestore(&nmk_chip->lock, flags); | ||
197 | |||
198 | nmk_gpio_irq_unmask(irq); | ||
199 | |||
200 | return 0; | ||
201 | } | ||
202 | |||
203 | static struct irq_chip nmk_gpio_irq_chip = { | ||
204 | .name = "Nomadik-GPIO", | ||
205 | .ack = nmk_gpio_irq_ack, | ||
206 | .mask = nmk_gpio_irq_mask, | ||
207 | .unmask = nmk_gpio_irq_unmask, | ||
208 | .set_type = nmk_gpio_irq_set_type, | ||
209 | }; | ||
210 | |||
211 | static void nmk_gpio_irq_handler(unsigned int irq, struct irq_desc *desc) | ||
212 | { | ||
213 | struct nmk_gpio_chip *nmk_chip; | ||
214 | struct irq_chip *host_chip; | ||
215 | unsigned int gpio_irq; | ||
216 | u32 pending; | ||
217 | unsigned int first_irq; | ||
218 | |||
219 | nmk_chip = get_irq_data(irq); | ||
220 | first_irq = NOMADIK_GPIO_TO_IRQ(nmk_chip->chip.base); | ||
221 | while ( (pending = readl(nmk_chip->addr + NMK_GPIO_IS)) ) { | ||
222 | gpio_irq = first_irq + __ffs(pending); | ||
223 | generic_handle_irq(gpio_irq); | ||
224 | } | ||
225 | if (0) {/* don't ack parent irq, as ack == disable */ | ||
226 | host_chip = get_irq_chip(irq); | ||
227 | host_chip->ack(irq); | ||
228 | } | ||
229 | } | ||
230 | |||
231 | static int nmk_gpio_init_irq(struct nmk_gpio_chip *nmk_chip) | ||
232 | { | ||
233 | unsigned int first_irq; | ||
234 | int i; | ||
235 | |||
236 | first_irq = NOMADIK_GPIO_TO_IRQ(nmk_chip->chip.base); | ||
237 | for (i = first_irq; i < first_irq + NMK_GPIO_PER_CHIP; i++) { | ||
238 | set_irq_chip(i, &nmk_gpio_irq_chip); | ||
239 | set_irq_handler(i, handle_edge_irq); | ||
240 | set_irq_flags(i, IRQF_VALID); | ||
241 | set_irq_chip_data(i, nmk_chip); | ||
242 | } | ||
243 | set_irq_chained_handler(nmk_chip->parent_irq, nmk_gpio_irq_handler); | ||
244 | set_irq_data(nmk_chip->parent_irq, nmk_chip); | ||
245 | return 0; | ||
246 | } | ||
247 | |||
248 | /* I/O Functions */ | ||
249 | static int nmk_gpio_make_input(struct gpio_chip *chip, unsigned offset) | ||
250 | { | ||
251 | struct nmk_gpio_chip *nmk_chip = | ||
252 | container_of(chip, struct nmk_gpio_chip, chip); | ||
253 | |||
254 | writel(1 << offset, nmk_chip->addr + NMK_GPIO_DIRC); | ||
255 | return 0; | ||
256 | } | ||
257 | |||
258 | static int nmk_gpio_make_output(struct gpio_chip *chip, unsigned offset, | ||
259 | int val) | ||
260 | { | ||
261 | struct nmk_gpio_chip *nmk_chip = | ||
262 | container_of(chip, struct nmk_gpio_chip, chip); | ||
263 | |||
264 | writel(1 << offset, nmk_chip->addr + NMK_GPIO_DIRS); | ||
265 | return 0; | ||
266 | } | ||
267 | |||
268 | static int nmk_gpio_get_input(struct gpio_chip *chip, unsigned offset) | ||
269 | { | ||
270 | struct nmk_gpio_chip *nmk_chip = | ||
271 | container_of(chip, struct nmk_gpio_chip, chip); | ||
272 | u32 bit = 1 << offset; | ||
273 | |||
274 | return (readl(nmk_chip->addr + NMK_GPIO_DAT) & bit) != 0; | ||
275 | } | ||
276 | |||
277 | static void nmk_gpio_set_output(struct gpio_chip *chip, unsigned offset, | ||
278 | int val) | ||
279 | { | ||
280 | struct nmk_gpio_chip *nmk_chip = | ||
281 | container_of(chip, struct nmk_gpio_chip, chip); | ||
282 | u32 bit = 1 << offset; | ||
283 | |||
284 | if (val) | ||
285 | writel(bit, nmk_chip->addr + NMK_GPIO_DATS); | ||
286 | else | ||
287 | writel(bit, nmk_chip->addr + NMK_GPIO_DATC); | ||
288 | } | ||
289 | |||
290 | /* This structure is replicated for each GPIO block allocated at probe time */ | ||
291 | static struct gpio_chip nmk_gpio_template = { | ||
292 | .direction_input = nmk_gpio_make_input, | ||
293 | .get = nmk_gpio_get_input, | ||
294 | .direction_output = nmk_gpio_make_output, | ||
295 | .set = nmk_gpio_set_output, | ||
296 | .ngpio = NMK_GPIO_PER_CHIP, | ||
297 | .can_sleep = 0, | ||
298 | }; | ||
299 | |||
300 | static int __init nmk_gpio_probe(struct amba_device *dev, struct amba_id *id) | ||
301 | { | ||
302 | struct nmk_gpio_platform_data *pdata; | ||
303 | struct nmk_gpio_chip *nmk_chip; | ||
304 | struct gpio_chip *chip; | ||
305 | int ret; | ||
306 | |||
307 | pdata = dev->dev.platform_data; | ||
308 | ret = amba_request_regions(dev, pdata->name); | ||
309 | if (ret) | ||
310 | return ret; | ||
311 | |||
312 | nmk_chip = kzalloc(sizeof(*nmk_chip), GFP_KERNEL); | ||
313 | if (!nmk_chip) { | ||
314 | ret = -ENOMEM; | ||
315 | goto out_amba; | ||
316 | } | ||
317 | /* | ||
318 | * The virt address in nmk_chip->addr is in the nomadik register space, | ||
319 | * so we can simply convert the resource address, without remapping | ||
320 | */ | ||
321 | nmk_chip->addr = io_p2v(dev->res.start); | ||
322 | nmk_chip->chip = nmk_gpio_template; | ||
323 | nmk_chip->parent_irq = pdata->parent_irq; | ||
324 | |||
325 | chip = &nmk_chip->chip; | ||
326 | chip->base = pdata->first_gpio; | ||
327 | chip->label = pdata->name; | ||
328 | chip->dev = &dev->dev; | ||
329 | chip->owner = THIS_MODULE; | ||
330 | |||
331 | ret = gpiochip_add(&nmk_chip->chip); | ||
332 | if (ret) | ||
333 | goto out_free; | ||
334 | |||
335 | amba_set_drvdata(dev, nmk_chip); | ||
336 | |||
337 | nmk_gpio_init_irq(nmk_chip); | ||
338 | |||
339 | dev_info(&dev->dev, "Bits %i-%i at address %p\n", | ||
340 | nmk_chip->chip.base, nmk_chip->chip.base+31, nmk_chip->addr); | ||
341 | return 0; | ||
342 | |||
343 | out_free: | ||
344 | kfree(nmk_chip); | ||
345 | out_amba: | ||
346 | amba_release_regions(dev); | ||
347 | dev_err(&dev->dev, "Failure %i for GPIO %i-%i\n", ret, | ||
348 | pdata->first_gpio, pdata->first_gpio+31); | ||
349 | return ret; | ||
350 | } | ||
351 | |||
352 | static int nmk_gpio_remove(struct amba_device *dev) | ||
353 | { | ||
354 | struct nmk_gpio_chip *nmk_chip; | ||
355 | |||
356 | nmk_chip = amba_get_drvdata(dev); | ||
357 | gpiochip_remove(&nmk_chip->chip); | ||
358 | kfree(nmk_chip); | ||
359 | amba_release_regions(dev); | ||
360 | return 0; | ||
361 | } | ||
362 | |||
363 | |||
364 | /* We have 0x1f080060 and 0x1f180060, accept both using the mask */ | ||
365 | static struct amba_id nmk_gpio_ids[] = { | ||
366 | { | ||
367 | .id = 0x1f080060, | ||
368 | .mask = 0xffefffff, | ||
369 | }, | ||
370 | {0, 0}, | ||
371 | }; | ||
372 | |||
373 | static struct amba_driver nmk_gpio_driver = { | ||
374 | .drv = { | ||
375 | .owner = THIS_MODULE, | ||
376 | .name = "gpio", | ||
377 | }, | ||
378 | .probe = nmk_gpio_probe, | ||
379 | .remove = nmk_gpio_remove, | ||
380 | .suspend = NULL, /* to be done */ | ||
381 | .resume = NULL, | ||
382 | .id_table = nmk_gpio_ids, | ||
383 | }; | ||
384 | |||
385 | static int __init nmk_gpio_init(void) | ||
386 | { | ||
387 | return amba_driver_register(&nmk_gpio_driver); | ||
388 | } | ||
389 | |||
390 | arch_initcall(nmk_gpio_init); | ||
391 | |||
392 | MODULE_AUTHOR("Prafulla WADASKAR and Alessandro Rubini"); | ||
393 | MODULE_DESCRIPTION("Nomadik GPIO Driver"); | ||
394 | MODULE_LICENSE("GPL"); | ||
395 | |||
396 | |||
diff --git a/arch/arm/mach-nomadik/i2c-8815nhk.c b/arch/arm/mach-nomadik/i2c-8815nhk.c new file mode 100644 index 000000000000..abfe25a08d6b --- /dev/null +++ b/arch/arm/mach-nomadik/i2c-8815nhk.c | |||
@@ -0,0 +1,65 @@ | |||
1 | #include <linux/module.h> | ||
2 | #include <linux/init.h> | ||
3 | #include <linux/i2c.h> | ||
4 | #include <linux/i2c-algo-bit.h> | ||
5 | #include <linux/i2c-gpio.h> | ||
6 | #include <linux/gpio.h> | ||
7 | #include <linux/platform_device.h> | ||
8 | |||
9 | /* | ||
10 | * There are two busses in the 8815NHK. | ||
11 | * They could, in theory, be driven by the hardware component, but we | ||
12 | * use bit-bang through GPIO by now, to keep things simple | ||
13 | */ | ||
14 | |||
15 | static struct i2c_gpio_platform_data nhk8815_i2c_data0 = { | ||
16 | /* keep defaults for timeouts; pins are push-pull bidirectional */ | ||
17 | .scl_pin = 62, | ||
18 | .sda_pin = 63, | ||
19 | }; | ||
20 | |||
21 | static struct i2c_gpio_platform_data nhk8815_i2c_data1 = { | ||
22 | /* keep defaults for timeouts; pins are push-pull bidirectional */ | ||
23 | .scl_pin = 53, | ||
24 | .sda_pin = 54, | ||
25 | }; | ||
26 | |||
27 | /* first bus: GPIO XX and YY */ | ||
28 | static struct platform_device nhk8815_i2c_dev0 = { | ||
29 | .name = "i2c-gpio", | ||
30 | .id = 0, | ||
31 | .dev = { | ||
32 | .platform_data = &nhk8815_i2c_data0, | ||
33 | }, | ||
34 | }; | ||
35 | /* second bus: GPIO XX and YY */ | ||
36 | static struct platform_device nhk8815_i2c_dev1 = { | ||
37 | .name = "i2c-gpio", | ||
38 | .id = 1, | ||
39 | .dev = { | ||
40 | .platform_data = &nhk8815_i2c_data1, | ||
41 | }, | ||
42 | }; | ||
43 | |||
44 | static int __init nhk8815_i2c_init(void) | ||
45 | { | ||
46 | nmk_gpio_set_mode(nhk8815_i2c_data0.scl_pin, NMK_GPIO_ALT_GPIO); | ||
47 | nmk_gpio_set_mode(nhk8815_i2c_data0.sda_pin, NMK_GPIO_ALT_GPIO); | ||
48 | platform_device_register(&nhk8815_i2c_dev0); | ||
49 | |||
50 | nmk_gpio_set_mode(nhk8815_i2c_data1.scl_pin, NMK_GPIO_ALT_GPIO); | ||
51 | nmk_gpio_set_mode(nhk8815_i2c_data1.sda_pin, NMK_GPIO_ALT_GPIO); | ||
52 | platform_device_register(&nhk8815_i2c_dev1); | ||
53 | |||
54 | return 0; | ||
55 | } | ||
56 | |||
57 | static void __exit nhk8815_i2c_exit(void) | ||
58 | { | ||
59 | platform_device_unregister(&nhk8815_i2c_dev0); | ||
60 | platform_device_unregister(&nhk8815_i2c_dev1); | ||
61 | return; | ||
62 | } | ||
63 | |||
64 | module_init(nhk8815_i2c_init); | ||
65 | module_exit(nhk8815_i2c_exit); | ||
diff --git a/arch/arm/mach-nomadik/include/mach/clkdev.h b/arch/arm/mach-nomadik/include/mach/clkdev.h new file mode 100644 index 000000000000..04b37a89801c --- /dev/null +++ b/arch/arm/mach-nomadik/include/mach/clkdev.h | |||
@@ -0,0 +1,7 @@ | |||
1 | #ifndef __ASM_MACH_CLKDEV_H | ||
2 | #define __ASM_MACH_CLKDEV_H | ||
3 | |||
4 | #define __clk_get(clk) ({ 1; }) | ||
5 | #define __clk_put(clk) do { } while (0) | ||
6 | |||
7 | #endif | ||
diff --git a/arch/arm/mach-nomadik/include/mach/debug-macro.S b/arch/arm/mach-nomadik/include/mach/debug-macro.S new file mode 100644 index 000000000000..e876990e1569 --- /dev/null +++ b/arch/arm/mach-nomadik/include/mach/debug-macro.S | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * Debugging macro include header | ||
3 | * | ||
4 | * Copyright (C) 1994-1999 Russell King | ||
5 | * Moved from linux/arch/arm/kernel/debug.S by Ben Dooks | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | * | ||
11 | */ | ||
12 | |||
13 | .macro addruart,rx | ||
14 | mrc p15, 0, \rx, c1, c0 | ||
15 | tst \rx, #1 @ MMU enabled? | ||
16 | moveq \rx, #0x10000000 @ physical base address | ||
17 | movne \rx, #0xf0000000 @ virtual base | ||
18 | add \rx, \rx, #0x00100000 | ||
19 | add \rx, \rx, #0x000fb000 | ||
20 | .endm | ||
21 | |||
22 | #include <asm/hardware/debug-pl01x.S> | ||
diff --git a/arch/arm/mach-nomadik/include/mach/entry-macro.S b/arch/arm/mach-nomadik/include/mach/entry-macro.S new file mode 100644 index 000000000000..49f1aa3bb420 --- /dev/null +++ b/arch/arm/mach-nomadik/include/mach/entry-macro.S | |||
@@ -0,0 +1,43 @@ | |||
1 | /* | ||
2 | * Low-level IRQ helper macros for Nomadik platforms | ||
3 | * | ||
4 | * This file is licensed under the terms of the GNU General Public | ||
5 | * License version 2. This program is licensed "as is" without any | ||
6 | * warranty of any kind, whether express or implied. | ||
7 | */ | ||
8 | |||
9 | #include <mach/hardware.h> | ||
10 | #include <mach/irqs.h> | ||
11 | |||
12 | .macro disable_fiq | ||
13 | .endm | ||
14 | |||
15 | .macro get_irqnr_preamble, base, tmp | ||
16 | ldr \base, =IO_ADDRESS(NOMADIK_IC_BASE) | ||
17 | .endm | ||
18 | |||
19 | .macro arch_ret_to_user, tmp1, tmp2 | ||
20 | .endm | ||
21 | |||
22 | .macro get_irqnr_and_base, irqnr, irqstat, base, tmp | ||
23 | |||
24 | /* This stanza gets the irq mask from one of two status registers */ | ||
25 | mov \irqnr, #0 | ||
26 | ldr \irqstat, [\base, #VIC_REG_IRQSR0] @ get masked status | ||
27 | cmp \irqstat, #0 | ||
28 | bne 1001f | ||
29 | add \irqnr, \irqnr, #32 | ||
30 | ldr \irqstat, [\base, #VIC_REG_IRQSR1] @ get masked status | ||
31 | |||
32 | 1001: tst \irqstat, #15 | ||
33 | bne 1002f | ||
34 | add \irqnr, \irqnr, #4 | ||
35 | movs \irqstat, \irqstat, lsr #4 | ||
36 | bne 1001b | ||
37 | 1002: tst \irqstat, #1 | ||
38 | bne 1003f | ||
39 | add \irqnr, \irqnr, #1 | ||
40 | movs \irqstat, \irqstat, lsr #1 | ||
41 | bne 1002b | ||
42 | 1003: /* EQ will be set if no irqs pending */ | ||
43 | .endm | ||
diff --git a/arch/arm/mach-nomadik/include/mach/gpio.h b/arch/arm/mach-nomadik/include/mach/gpio.h new file mode 100644 index 000000000000..61577c9f9a7d --- /dev/null +++ b/arch/arm/mach-nomadik/include/mach/gpio.h | |||
@@ -0,0 +1,71 @@ | |||
1 | /* | ||
2 | * Structures and registers for GPIO access in the Nomadik SoC | ||
3 | * | ||
4 | * Copyright (C) 2008 STMicroelectronics | ||
5 | * Author: Prafulla WADASKAR <prafulla.wadaskar@st.com> | ||
6 | * Copyright (C) 2009 Alessandro Rubini <rubini@unipv.it> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | #ifndef __ASM_ARCH_GPIO_H | ||
13 | #define __ASM_ARCH_GPIO_H | ||
14 | |||
15 | #include <asm-generic/gpio.h> | ||
16 | |||
17 | /* | ||
18 | * These currently cause a function call to happen, they may be optimized | ||
19 | * if needed by adding cpu-specific defines to identify blocks | ||
20 | * (see mach-pxa/include/mach/gpio.h as an example using GPLR etc) | ||
21 | */ | ||
22 | #define gpio_get_value __gpio_get_value | ||
23 | #define gpio_set_value __gpio_set_value | ||
24 | #define gpio_cansleep __gpio_cansleep | ||
25 | #define gpio_to_irq __gpio_to_irq | ||
26 | |||
27 | /* | ||
28 | * "nmk_gpio" and "NMK_GPIO" stand for "Nomadik GPIO", leaving | ||
29 | * the "gpio" namespace for generic and cross-machine functions | ||
30 | */ | ||
31 | |||
32 | /* Register in the logic block */ | ||
33 | #define NMK_GPIO_DAT 0x00 | ||
34 | #define NMK_GPIO_DATS 0x04 | ||
35 | #define NMK_GPIO_DATC 0x08 | ||
36 | #define NMK_GPIO_PDIS 0x0c | ||
37 | #define NMK_GPIO_DIR 0x10 | ||
38 | #define NMK_GPIO_DIRS 0x14 | ||
39 | #define NMK_GPIO_DIRC 0x18 | ||
40 | #define NMK_GPIO_SLPC 0x1c | ||
41 | #define NMK_GPIO_AFSLA 0x20 | ||
42 | #define NMK_GPIO_AFSLB 0x24 | ||
43 | |||
44 | #define NMK_GPIO_RIMSC 0x40 | ||
45 | #define NMK_GPIO_FIMSC 0x44 | ||
46 | #define NMK_GPIO_IS 0x48 | ||
47 | #define NMK_GPIO_IC 0x4c | ||
48 | #define NMK_GPIO_RWIMSC 0x50 | ||
49 | #define NMK_GPIO_FWIMSC 0x54 | ||
50 | #define NMK_GPIO_WKS 0x58 | ||
51 | |||
52 | /* Alternate functions: function C is set in hw by setting both A and B */ | ||
53 | #define NMK_GPIO_ALT_GPIO 0 | ||
54 | #define NMK_GPIO_ALT_A 1 | ||
55 | #define NMK_GPIO_ALT_B 2 | ||
56 | #define NMK_GPIO_ALT_C (NMK_GPIO_ALT_A | NMK_GPIO_ALT_B) | ||
57 | |||
58 | extern int nmk_gpio_set_mode(int gpio, int gpio_mode); | ||
59 | extern int nmk_gpio_get_mode(int gpio); | ||
60 | |||
61 | /* | ||
62 | * Platform data to register a block: only the initial gpio/irq number. | ||
63 | */ | ||
64 | struct nmk_gpio_platform_data { | ||
65 | char *name; | ||
66 | int first_gpio; | ||
67 | int first_irq; | ||
68 | int parent_irq; | ||
69 | }; | ||
70 | |||
71 | #endif /* __ASM_ARCH_GPIO_H */ | ||
diff --git a/arch/arm/mach-nomadik/include/mach/hardware.h b/arch/arm/mach-nomadik/include/mach/hardware.h new file mode 100644 index 000000000000..6316dba3bfc8 --- /dev/null +++ b/arch/arm/mach-nomadik/include/mach/hardware.h | |||
@@ -0,0 +1,90 @@ | |||
1 | /* | ||
2 | * This file contains the hardware definitions of the Nomadik. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * YOU should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
17 | */ | ||
18 | #ifndef __ASM_ARCH_HARDWARE_H | ||
19 | #define __ASM_ARCH_HARDWARE_H | ||
20 | |||
21 | /* Nomadik registers live from 0x1000.0000 to 0x1023.0000 -- currently */ | ||
22 | #define NOMADIK_IO_VIRTUAL 0xF0000000 /* VA of IO */ | ||
23 | #define NOMADIK_IO_PHYSICAL 0x10000000 /* PA of IO */ | ||
24 | #define NOMADIK_IO_SIZE 0x00300000 /* 3MB for all regs */ | ||
25 | |||
26 | /* used in C code, so cast to proper type */ | ||
27 | #define io_p2v(x) ((void __iomem *)(x) \ | ||
28 | - NOMADIK_IO_PHYSICAL + NOMADIK_IO_VIRTUAL) | ||
29 | #define io_v2p(x) ((unsigned long)(x) \ | ||
30 | - NOMADIK_IO_VIRTUAL + NOMADIK_IO_PHYSICAL) | ||
31 | |||
32 | /* used in asm code, so no casts */ | ||
33 | #define IO_ADDRESS(x) ((x) - NOMADIK_IO_PHYSICAL + NOMADIK_IO_VIRTUAL) | ||
34 | |||
35 | /* | ||
36 | * Base address defination for Nomadik Onchip Logic Block | ||
37 | */ | ||
38 | #define NOMADIK_FSMC_BASE 0x10100000 /* FSMC registers */ | ||
39 | #define NOMADIK_SDRAMC_BASE 0x10110000 /* SDRAM Controller */ | ||
40 | #define NOMADIK_CLCDC_BASE 0x10120000 /* CLCD Controller */ | ||
41 | #define NOMADIK_MDIF_BASE 0x10120000 /* MDIF */ | ||
42 | #define NOMADIK_DMA0_BASE 0x10130000 /* DMA0 Controller */ | ||
43 | #define NOMADIK_IC_BASE 0x10140000 /* Vectored Irq Controller */ | ||
44 | #define NOMADIK_DMA1_BASE 0x10150000 /* DMA1 Controller */ | ||
45 | #define NOMADIK_USB_BASE 0x10170000 /* USB-OTG conf reg base */ | ||
46 | #define NOMADIK_CRYP_BASE 0x10180000 /* Crypto processor */ | ||
47 | #define NOMADIK_SHA1_BASE 0x10190000 /* SHA-1 Processor */ | ||
48 | #define NOMADIK_XTI_BASE 0x101A0000 /* XTI */ | ||
49 | #define NOMADIK_RNG_BASE 0x101B0000 /* Random number generator */ | ||
50 | #define NOMADIK_SRC_BASE 0x101E0000 /* SRC base */ | ||
51 | #define NOMADIK_WDOG_BASE 0x101E1000 /* Watchdog */ | ||
52 | #define NOMADIK_MTU0_BASE 0x101E2000 /* Multiple Timer 0 */ | ||
53 | #define NOMADIK_MTU1_BASE 0x101E3000 /* Multiple Timer 1 */ | ||
54 | #define NOMADIK_GPIO0_BASE 0x101E4000 /* GPIO0 */ | ||
55 | #define NOMADIK_GPIO1_BASE 0x101E5000 /* GPIO1 */ | ||
56 | #define NOMADIK_GPIO2_BASE 0x101E6000 /* GPIO2 */ | ||
57 | #define NOMADIK_GPIO3_BASE 0x101E7000 /* GPIO3 */ | ||
58 | #define NOMADIK_RTC_BASE 0x101E8000 /* Real Time Clock base */ | ||
59 | #define NOMADIK_PMU_BASE 0x101E9000 /* Power Management Unit */ | ||
60 | #define NOMADIK_OWM_BASE 0x101EA000 /* One wire master */ | ||
61 | #define NOMADIK_SCR_BASE 0x101EF000 /* Secure Control registers */ | ||
62 | #define NOMADIK_MSP2_BASE 0x101F0000 /* MSP 2 interface */ | ||
63 | #define NOMADIK_MSP1_BASE 0x101F1000 /* MSP 1 interface */ | ||
64 | #define NOMADIK_UART2_BASE 0x101F2000 /* UART 2 interface */ | ||
65 | #define NOMADIK_SSIRx_BASE 0x101F3000 /* SSI 8-ch rx interface */ | ||
66 | #define NOMADIK_SSITx_BASE 0x101F4000 /* SSI 8-ch tx interface */ | ||
67 | #define NOMADIK_MSHC_BASE 0x101F5000 /* Memory Stick(Pro) Host */ | ||
68 | #define NOMADIK_SDI_BASE 0x101F6000 /* SD-card/MM-Card */ | ||
69 | #define NOMADIK_I2C1_BASE 0x101F7000 /* I2C1 interface */ | ||
70 | #define NOMADIK_I2C0_BASE 0x101F8000 /* I2C0 interface */ | ||
71 | #define NOMADIK_MSP0_BASE 0x101F9000 /* MSP 0 interface */ | ||
72 | #define NOMADIK_FIRDA_BASE 0x101FA000 /* FIrDA interface */ | ||
73 | #define NOMADIK_UART1_BASE 0x101FB000 /* UART 1 interface */ | ||
74 | #define NOMADIK_SSP_BASE 0x101FC000 /* SSP interface */ | ||
75 | #define NOMADIK_UART0_BASE 0x101FD000 /* UART 0 interface */ | ||
76 | #define NOMADIK_SGA_BASE 0x101FE000 /* SGA interface */ | ||
77 | #define NOMADIK_L2CC_BASE 0x10210000 /* L2 Cache controller */ | ||
78 | |||
79 | /* Other ranges, not for p2v/v2p */ | ||
80 | #define NOMADIK_BACKUP_RAM 0x80010000 | ||
81 | #define NOMADIK_EBROM 0x80000000 /* Embedded boot ROM */ | ||
82 | #define NOMADIK_HAMACV_DMEM_BASE 0xA0100000 /* HAMACV Data Memory Start */ | ||
83 | #define NOMADIK_HAMACV_DMEM_END 0xA01FFFFF /* HAMACV Data Memory End */ | ||
84 | #define NOMADIK_HAMACA_DMEM 0xA0200000 /* HAMACA Data Memory Space */ | ||
85 | |||
86 | #define NOMADIK_FSMC_VA IO_ADDRESS(NOMADIK_FSMC_BASE) | ||
87 | #define NOMADIK_MTU0_VA IO_ADDRESS(NOMADIK_MTU0_BASE) | ||
88 | #define NOMADIK_MTU1_VA IO_ADDRESS(NOMADIK_MTU1_BASE) | ||
89 | |||
90 | #endif /* __ASM_ARCH_HARDWARE_H */ | ||
diff --git a/arch/arm/mach-nomadik/include/mach/io.h b/arch/arm/mach-nomadik/include/mach/io.h new file mode 100644 index 000000000000..2e1eca1b8243 --- /dev/null +++ b/arch/arm/mach-nomadik/include/mach/io.h | |||
@@ -0,0 +1,22 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-nomadik/include/mach/io.h (copied from mach-sa1100) | ||
3 | * | ||
4 | * Copyright (C) 1997-1999 Russell King | ||
5 | * | ||
6 | * Modifications: | ||
7 | * 06-12-1997 RMK Created. | ||
8 | * 07-04-1999 RMK Major cleanup | ||
9 | */ | ||
10 | #ifndef __ASM_ARM_ARCH_IO_H | ||
11 | #define __ASM_ARM_ARCH_IO_H | ||
12 | |||
13 | #define IO_SPACE_LIMIT 0xffffffff | ||
14 | |||
15 | /* | ||
16 | * We don't actually have real ISA nor PCI buses, but there is so many | ||
17 | * drivers out there that might just work if we fake them... | ||
18 | */ | ||
19 | #define __io(a) __typesafe_io(a) | ||
20 | #define __mem_pci(a) (a) | ||
21 | |||
22 | #endif | ||
diff --git a/arch/arm/mach-nomadik/include/mach/irqs.h b/arch/arm/mach-nomadik/include/mach/irqs.h new file mode 100644 index 000000000000..8faabc560398 --- /dev/null +++ b/arch/arm/mach-nomadik/include/mach/irqs.h | |||
@@ -0,0 +1,82 @@ | |||
1 | /* | ||
2 | * mach-nomadik/include/mach/irqs.h | ||
3 | * | ||
4 | * Copyright (C) ST Microelectronics | ||
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 as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | #ifndef __ASM_ARCH_IRQS_H | ||
21 | #define __ASM_ARCH_IRQS_H | ||
22 | |||
23 | #include <mach/hardware.h> | ||
24 | |||
25 | #define IRQ_VIC_START 0 /* first VIC interrupt is 0 */ | ||
26 | |||
27 | /* | ||
28 | * Interrupt numbers generic for all Nomadik Chip cuts | ||
29 | */ | ||
30 | #define IRQ_WATCHDOG 0 | ||
31 | #define IRQ_SOFTINT 1 | ||
32 | #define IRQ_CRYPTO 2 | ||
33 | #define IRQ_OWM 3 | ||
34 | #define IRQ_MTU0 4 | ||
35 | #define IRQ_MTU1 5 | ||
36 | #define IRQ_GPIO0 6 | ||
37 | #define IRQ_GPIO1 7 | ||
38 | #define IRQ_GPIO2 8 | ||
39 | #define IRQ_GPIO3 9 | ||
40 | #define IRQ_RTC_RTT 10 | ||
41 | #define IRQ_SSP 11 | ||
42 | #define IRQ_UART0 12 | ||
43 | #define IRQ_DMA1 13 | ||
44 | #define IRQ_CLCD_MDIF 14 | ||
45 | #define IRQ_DMA0 15 | ||
46 | #define IRQ_PWRFAIL 16 | ||
47 | #define IRQ_UART1 17 | ||
48 | #define IRQ_FIRDA 18 | ||
49 | #define IRQ_MSP0 19 | ||
50 | #define IRQ_I2C0 20 | ||
51 | #define IRQ_I2C1 21 | ||
52 | #define IRQ_SDMMC 22 | ||
53 | #define IRQ_USBOTG 23 | ||
54 | #define IRQ_SVA_IT0 24 | ||
55 | #define IRQ_SVA_IT1 25 | ||
56 | #define IRQ_SAA_IT0 26 | ||
57 | #define IRQ_SAA_IT1 27 | ||
58 | #define IRQ_UART2 28 | ||
59 | #define IRQ_MSP2 31 | ||
60 | #define IRQ_L2CC 48 | ||
61 | #define IRQ_HPI 49 | ||
62 | #define IRQ_SKE 50 | ||
63 | #define IRQ_KP 51 | ||
64 | #define IRQ_MEMST 54 | ||
65 | #define IRQ_SGA_IT 58 | ||
66 | #define IRQ_USBM 60 | ||
67 | #define IRQ_MSP1 62 | ||
68 | |||
69 | #define NOMADIK_SOC_NR_IRQS 64 | ||
70 | |||
71 | /* After chip-specific IRQ numbers we have the GPIO ones */ | ||
72 | #define NOMADIK_NR_GPIO 128 /* last 4 not wired to pins */ | ||
73 | #define NOMADIK_GPIO_TO_IRQ(gpio) ((gpio) + NOMADIK_SOC_NR_IRQS) | ||
74 | #define NOMADIK_IRQ_TO_GPIO(irq) ((irq) - NOMADIK_SOC_NR_IRQS) | ||
75 | #define NR_IRQS NOMADIK_GPIO_TO_IRQ(NOMADIK_NR_GPIO) | ||
76 | |||
77 | /* Following two are used by entry_macro.S, to access our dual-vic */ | ||
78 | #define VIC_REG_IRQSR0 0 | ||
79 | #define VIC_REG_IRQSR1 0x20 | ||
80 | |||
81 | #endif /* __ASM_ARCH_IRQS_H */ | ||
82 | |||
diff --git a/arch/arm/mach-nomadik/include/mach/memory.h b/arch/arm/mach-nomadik/include/mach/memory.h new file mode 100644 index 000000000000..1e5689d98ecd --- /dev/null +++ b/arch/arm/mach-nomadik/include/mach/memory.h | |||
@@ -0,0 +1,28 @@ | |||
1 | /* | ||
2 | * mach-nomadik/include/mach/memory.h | ||
3 | * | ||
4 | * Copyright (C) 1999 ARM Limited | ||
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 as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | #ifndef __ASM_ARCH_MEMORY_H | ||
21 | #define __ASM_ARCH_MEMORY_H | ||
22 | |||
23 | /* | ||
24 | * Physical DRAM offset. | ||
25 | */ | ||
26 | #define PHYS_OFFSET UL(0x00000000) | ||
27 | |||
28 | #endif | ||
diff --git a/arch/arm/mach-nomadik/include/mach/mtu.h b/arch/arm/mach-nomadik/include/mach/mtu.h new file mode 100644 index 000000000000..76da7f085330 --- /dev/null +++ b/arch/arm/mach-nomadik/include/mach/mtu.h | |||
@@ -0,0 +1,45 @@ | |||
1 | #ifndef __ASM_ARCH_MTU_H | ||
2 | #define __ASM_ARCH_MTU_H | ||
3 | |||
4 | /* | ||
5 | * The MTU device hosts four different counters, with 4 set of | ||
6 | * registers. These are register names. | ||
7 | */ | ||
8 | |||
9 | #define MTU_IMSC 0x00 /* Interrupt mask set/clear */ | ||
10 | #define MTU_RIS 0x04 /* Raw interrupt status */ | ||
11 | #define MTU_MIS 0x08 /* Masked interrupt status */ | ||
12 | #define MTU_ICR 0x0C /* Interrupt clear register */ | ||
13 | |||
14 | /* per-timer registers take 0..3 as argument */ | ||
15 | #define MTU_LR(x) (0x10 + 0x10 * (x) + 0x00) /* Load value */ | ||
16 | #define MTU_VAL(x) (0x10 + 0x10 * (x) + 0x04) /* Current value */ | ||
17 | #define MTU_CR(x) (0x10 + 0x10 * (x) + 0x08) /* Control reg */ | ||
18 | #define MTU_BGLR(x) (0x10 + 0x10 * (x) + 0x0c) /* At next overflow */ | ||
19 | |||
20 | /* bits for the control register */ | ||
21 | #define MTU_CRn_ENA 0x80 | ||
22 | #define MTU_CRn_PERIODIC 0x40 /* if 0 = free-running */ | ||
23 | #define MTU_CRn_PRESCALE_MASK 0x0c | ||
24 | #define MTU_CRn_PRESCALE_1 0x00 | ||
25 | #define MTU_CRn_PRESCALE_16 0x04 | ||
26 | #define MTU_CRn_PRESCALE_256 0x08 | ||
27 | #define MTU_CRn_32BITS 0x02 | ||
28 | #define MTU_CRn_ONESHOT 0x01 /* if 0 = wraps reloading from BGLR*/ | ||
29 | |||
30 | /* Other registers are usual amba/primecell registers, currently not used */ | ||
31 | #define MTU_ITCR 0xff0 | ||
32 | #define MTU_ITOP 0xff4 | ||
33 | |||
34 | #define MTU_PERIPH_ID0 0xfe0 | ||
35 | #define MTU_PERIPH_ID1 0xfe4 | ||
36 | #define MTU_PERIPH_ID2 0xfe8 | ||
37 | #define MTU_PERIPH_ID3 0xfeC | ||
38 | |||
39 | #define MTU_PCELL0 0xff0 | ||
40 | #define MTU_PCELL1 0xff4 | ||
41 | #define MTU_PCELL2 0xff8 | ||
42 | #define MTU_PCELL3 0xffC | ||
43 | |||
44 | #endif /* __ASM_ARCH_MTU_H */ | ||
45 | |||
diff --git a/arch/arm/mach-nomadik/include/mach/setup.h b/arch/arm/mach-nomadik/include/mach/setup.h new file mode 100644 index 000000000000..a4e468cf63da --- /dev/null +++ b/arch/arm/mach-nomadik/include/mach/setup.h | |||
@@ -0,0 +1,22 @@ | |||
1 | |||
2 | /* | ||
3 | * These symbols are needed for board-specific files to call their | ||
4 | * own cpu-specific files | ||
5 | */ | ||
6 | |||
7 | #ifndef __ASM_ARCH_SETUP_H | ||
8 | #define __ASM_ARCH_SETUP_H | ||
9 | |||
10 | #include <asm/mach/time.h> | ||
11 | #include <linux/init.h> | ||
12 | |||
13 | #ifdef CONFIG_NOMADIK_8815 | ||
14 | |||
15 | extern void cpu8815_map_io(void); | ||
16 | extern void cpu8815_platform_init(void); | ||
17 | extern void cpu8815_init_irq(void); | ||
18 | extern struct sys_timer nomadik_timer; | ||
19 | |||
20 | #endif /* NOMADIK_8815 */ | ||
21 | |||
22 | #endif /* __ASM_ARCH_SETUP_H */ | ||
diff --git a/arch/arm/mach-nomadik/include/mach/system.h b/arch/arm/mach-nomadik/include/mach/system.h new file mode 100644 index 000000000000..7119f688116e --- /dev/null +++ b/arch/arm/mach-nomadik/include/mach/system.h | |||
@@ -0,0 +1,45 @@ | |||
1 | /* | ||
2 | * mach-nomadik/include/mach/system.h | ||
3 | * | ||
4 | * Copyright (C) 2008 STMicroelectronics | ||
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 as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | #ifndef __ASM_ARCH_SYSTEM_H | ||
21 | #define __ASM_ARCH_SYSTEM_H | ||
22 | |||
23 | #include <linux/io.h> | ||
24 | #include <mach/hardware.h> | ||
25 | |||
26 | static inline void arch_idle(void) | ||
27 | { | ||
28 | /* | ||
29 | * This should do all the clock switching | ||
30 | * and wait for interrupt tricks | ||
31 | */ | ||
32 | cpu_do_idle(); | ||
33 | } | ||
34 | |||
35 | static inline void arch_reset(char mode, const char *cmd) | ||
36 | { | ||
37 | void __iomem *src_rstsr = io_p2v(NOMADIK_SRC_BASE + 0x18); | ||
38 | |||
39 | /* FIXME: use egpio when implemented */ | ||
40 | |||
41 | /* Write anything to Reset status register */ | ||
42 | writel(1, src_rstsr); | ||
43 | } | ||
44 | |||
45 | #endif | ||
diff --git a/arch/arm/mach-nomadik/include/mach/timex.h b/arch/arm/mach-nomadik/include/mach/timex.h new file mode 100644 index 000000000000..318b8896ce96 --- /dev/null +++ b/arch/arm/mach-nomadik/include/mach/timex.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __ASM_ARCH_TIMEX_H | ||
2 | #define __ASM_ARCH_TIMEX_H | ||
3 | |||
4 | #define CLOCK_TICK_RATE 2400000 | ||
5 | |||
6 | #endif | ||
diff --git a/arch/arm/mach-nomadik/include/mach/uncompress.h b/arch/arm/mach-nomadik/include/mach/uncompress.h new file mode 100644 index 000000000000..071003bc8456 --- /dev/null +++ b/arch/arm/mach-nomadik/include/mach/uncompress.h | |||
@@ -0,0 +1,63 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2008 STMicroelectronics | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
17 | */ | ||
18 | |||
19 | #ifndef __ASM_ARCH_UNCOMPRESS_H | ||
20 | #define __ASM_ARCH_UNCOMPRESS_H | ||
21 | |||
22 | #include <asm/setup.h> | ||
23 | #include <asm/io.h> | ||
24 | #include <mach/hardware.h> | ||
25 | |||
26 | /* we need the constants in amba/serial.h, but it refers to amba_device */ | ||
27 | struct amba_device; | ||
28 | #include <linux/amba/serial.h> | ||
29 | |||
30 | #define NOMADIK_UART_DR 0x101FB000 | ||
31 | #define NOMADIK_UART_LCRH 0x101FB02c | ||
32 | #define NOMADIK_UART_CR 0x101FB030 | ||
33 | #define NOMADIK_UART_FR 0x101FB018 | ||
34 | |||
35 | static void putc(const char c) | ||
36 | { | ||
37 | /* Do nothing if the UART is not enabled. */ | ||
38 | if (!(readb(NOMADIK_UART_CR) & UART01x_CR_UARTEN)) | ||
39 | return; | ||
40 | |||
41 | if (c == '\n') | ||
42 | putc('\r'); | ||
43 | |||
44 | while (readb(NOMADIK_UART_FR) & UART01x_FR_TXFF) | ||
45 | barrier(); | ||
46 | writeb(c, NOMADIK_UART_DR); | ||
47 | } | ||
48 | |||
49 | static void flush(void) | ||
50 | { | ||
51 | if (!(readb(NOMADIK_UART_CR) & UART01x_CR_UARTEN)) | ||
52 | return; | ||
53 | while (readb(NOMADIK_UART_FR) & UART01x_FR_BUSY) | ||
54 | barrier(); | ||
55 | } | ||
56 | |||
57 | static inline void arch_decomp_setup(void) | ||
58 | { | ||
59 | } | ||
60 | |||
61 | #define arch_decomp_wdog() /* nothing to do here */ | ||
62 | |||
63 | #endif /* __ASM_ARCH_UNCOMPRESS_H */ | ||
diff --git a/arch/arm/mach-nomadik/include/mach/vmalloc.h b/arch/arm/mach-nomadik/include/mach/vmalloc.h new file mode 100644 index 000000000000..be12e31ea528 --- /dev/null +++ b/arch/arm/mach-nomadik/include/mach/vmalloc.h | |||
@@ -0,0 +1,2 @@ | |||
1 | |||
2 | #define VMALLOC_END 0xe8000000 | ||
diff --git a/arch/arm/mach-nomadik/timer.c b/arch/arm/mach-nomadik/timer.c new file mode 100644 index 000000000000..d1738e7061d4 --- /dev/null +++ b/arch/arm/mach-nomadik/timer.c | |||
@@ -0,0 +1,164 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/mach-nomadik/timer.c | ||
3 | * | ||
4 | * Copyright (C) 2008 STMicroelectronics | ||
5 | * Copyright (C) 2009 Alessandro Rubini, somewhat based on at91sam926x | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2, as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | #include <linux/init.h> | ||
12 | #include <linux/interrupt.h> | ||
13 | #include <linux/irq.h> | ||
14 | #include <linux/io.h> | ||
15 | #include <linux/clockchips.h> | ||
16 | #include <linux/jiffies.h> | ||
17 | #include <asm/mach/time.h> | ||
18 | #include <mach/mtu.h> | ||
19 | |||
20 | #define TIMER_CTRL 0x80 /* No divisor */ | ||
21 | #define TIMER_PERIODIC 0x40 | ||
22 | #define TIMER_SZ32BIT 0x02 | ||
23 | |||
24 | /* Initial value for SRC control register: all timers use MXTAL/8 source */ | ||
25 | #define SRC_CR_INIT_MASK 0x00007fff | ||
26 | #define SRC_CR_INIT_VAL 0x2aaa8000 | ||
27 | |||
28 | static u32 nmdk_count; /* accumulated count */ | ||
29 | static u32 nmdk_cycle; /* write-once */ | ||
30 | static __iomem void *mtu_base; | ||
31 | |||
32 | /* | ||
33 | * clocksource: the MTU device is a decrementing counters, so we negate | ||
34 | * the value being read. | ||
35 | */ | ||
36 | static cycle_t nmdk_read_timer(struct clocksource *cs) | ||
37 | { | ||
38 | u32 count = readl(mtu_base + MTU_VAL(0)); | ||
39 | return nmdk_count + nmdk_cycle - count; | ||
40 | |||
41 | } | ||
42 | |||
43 | static struct clocksource nmdk_clksrc = { | ||
44 | .name = "mtu_0", | ||
45 | .rating = 120, | ||
46 | .read = nmdk_read_timer, | ||
47 | .shift = 20, | ||
48 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | ||
49 | }; | ||
50 | |||
51 | /* | ||
52 | * Clockevent device: currently only periodic mode is supported | ||
53 | */ | ||
54 | static void nmdk_clkevt_mode(enum clock_event_mode mode, | ||
55 | struct clock_event_device *dev) | ||
56 | { | ||
57 | unsigned long flags; | ||
58 | |||
59 | switch (mode) { | ||
60 | case CLOCK_EVT_MODE_PERIODIC: | ||
61 | /* enable interrupts -- and count current value? */ | ||
62 | raw_local_irq_save(flags); | ||
63 | writel(readl(mtu_base + MTU_IMSC) | 1, mtu_base + MTU_IMSC); | ||
64 | raw_local_irq_restore(flags); | ||
65 | break; | ||
66 | case CLOCK_EVT_MODE_ONESHOT: | ||
67 | BUG(); /* Not supported, yet */ | ||
68 | /* FALLTHROUGH */ | ||
69 | case CLOCK_EVT_MODE_SHUTDOWN: | ||
70 | case CLOCK_EVT_MODE_UNUSED: | ||
71 | /* disable irq */ | ||
72 | raw_local_irq_save(flags); | ||
73 | writel(readl(mtu_base + MTU_IMSC) & ~1, mtu_base + MTU_IMSC); | ||
74 | raw_local_irq_restore(flags); | ||
75 | break; | ||
76 | case CLOCK_EVT_MODE_RESUME: | ||
77 | break; | ||
78 | } | ||
79 | } | ||
80 | |||
81 | static struct clock_event_device nmdk_clkevt = { | ||
82 | .name = "mtu_0", | ||
83 | .features = CLOCK_EVT_FEAT_PERIODIC, | ||
84 | .shift = 32, | ||
85 | .rating = 100, | ||
86 | .set_mode = nmdk_clkevt_mode, | ||
87 | }; | ||
88 | |||
89 | /* | ||
90 | * IRQ Handler for the timer 0 of the MTU block. The irq is not shared | ||
91 | * as we are the only users of mtu0 by now. | ||
92 | */ | ||
93 | static irqreturn_t nmdk_timer_interrupt(int irq, void *dev_id) | ||
94 | { | ||
95 | /* ack: "interrupt clear register" */ | ||
96 | writel( 1 << 0, mtu_base + MTU_ICR); | ||
97 | |||
98 | /* we can't count lost ticks, unfortunately */ | ||
99 | nmdk_count += nmdk_cycle; | ||
100 | nmdk_clkevt.event_handler(&nmdk_clkevt); | ||
101 | |||
102 | return IRQ_HANDLED; | ||
103 | } | ||
104 | |||
105 | /* | ||
106 | * Set up timer interrupt, and return the current time in seconds. | ||
107 | */ | ||
108 | static struct irqaction nmdk_timer_irq = { | ||
109 | .name = "Nomadik Timer Tick", | ||
110 | .flags = IRQF_DISABLED | IRQF_TIMER, | ||
111 | .handler = nmdk_timer_interrupt, | ||
112 | }; | ||
113 | |||
114 | static void nmdk_timer_reset(void) | ||
115 | { | ||
116 | u32 cr; | ||
117 | |||
118 | writel(0, mtu_base + MTU_CR(0)); /* off */ | ||
119 | |||
120 | /* configure load and background-load, and fire it up */ | ||
121 | writel(nmdk_cycle, mtu_base + MTU_LR(0)); | ||
122 | writel(nmdk_cycle, mtu_base + MTU_BGLR(0)); | ||
123 | cr = MTU_CRn_PERIODIC | MTU_CRn_PRESCALE_1 | MTU_CRn_32BITS; | ||
124 | writel(cr, mtu_base + MTU_CR(0)); | ||
125 | writel(cr | MTU_CRn_ENA, mtu_base + MTU_CR(0)); | ||
126 | } | ||
127 | |||
128 | static void __init nmdk_timer_init(void) | ||
129 | { | ||
130 | u32 src_cr; | ||
131 | unsigned long rate; | ||
132 | int bits; | ||
133 | |||
134 | rate = CLOCK_TICK_RATE; /* 2.4MHz */ | ||
135 | nmdk_cycle = (rate + HZ/2) / HZ; | ||
136 | |||
137 | /* Configure timer sources in "system reset controller" ctrl reg */ | ||
138 | src_cr = readl(io_p2v(NOMADIK_SRC_BASE)); | ||
139 | src_cr &= SRC_CR_INIT_MASK; | ||
140 | src_cr |= SRC_CR_INIT_VAL; | ||
141 | writel(src_cr, io_p2v(NOMADIK_SRC_BASE)); | ||
142 | |||
143 | /* Save global pointer to mtu, used by functions above */ | ||
144 | mtu_base = io_p2v(NOMADIK_MTU0_BASE); | ||
145 | |||
146 | /* Init the timer and register clocksource */ | ||
147 | nmdk_timer_reset(); | ||
148 | |||
149 | nmdk_clksrc.mult = clocksource_hz2mult(rate, nmdk_clksrc.shift); | ||
150 | bits = 8*sizeof(nmdk_count); | ||
151 | nmdk_clksrc.mask = CLOCKSOURCE_MASK(bits); | ||
152 | |||
153 | clocksource_register(&nmdk_clksrc); | ||
154 | |||
155 | /* Register irq and clockevents */ | ||
156 | setup_irq(IRQ_MTU0, &nmdk_timer_irq); | ||
157 | nmdk_clkevt.mult = div_sc(rate, NSEC_PER_SEC, nmdk_clkevt.shift); | ||
158 | nmdk_clkevt.cpumask = cpumask_of(0); | ||
159 | clockevents_register_device(&nmdk_clkevt); | ||
160 | } | ||
161 | |||
162 | struct sys_timer nomadik_timer = { | ||
163 | .init = nmdk_timer_init, | ||
164 | }; | ||