Alessandro Rubini | 28ad94e | 2009-07-02 19:06:47 +0100 | [diff] [blame] | 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> |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 22 | #include <linux/amba/bus.h> |
Rabin Vincent | 3e3c62c | 2010-03-03 04:52:34 +0100 | [diff] [blame] | 23 | #include <linux/platform_device.h> |
Russell King | 35b47a405 | 2011-11-28 10:48:02 +0000 | [diff] [blame] | 24 | #include <linux/io.h> |
Linus Walleij | 7c77852 | 2012-01-09 12:40:02 +0100 | [diff] [blame^] | 25 | #include <linux/slab.h> |
| 26 | #include <linux/irq.h> |
| 27 | #include <linux/dma-mapping.h> |
Alessandro Rubini | 28ad94e | 2009-07-02 19:06:47 +0100 | [diff] [blame] | 28 | |
Linus Walleij | 0f33286 | 2011-08-22 08:33:30 +0100 | [diff] [blame] | 29 | #include <plat/gpio-nomadik.h> |
Alessandro Rubini | 28ad94e | 2009-07-02 19:06:47 +0100 | [diff] [blame] | 30 | #include <mach/hardware.h> |
| 31 | #include <mach/irqs.h> |
| 32 | #include <asm/mach/map.h> |
| 33 | #include <asm/hardware/vic.h> |
| 34 | |
Alessandro Rubini | 0b260fd | 2009-07-02 15:29:43 +0100 | [diff] [blame] | 35 | #include <asm/cacheflush.h> |
| 36 | #include <asm/hardware/cache-l2x0.h> |
| 37 | |
Linus Walleij | ba327b1 | 2010-05-26 07:38:54 +0100 | [diff] [blame] | 38 | #include "clock.h" |
Linus Walleij | 61b3875 | 2011-11-28 12:20:53 +0100 | [diff] [blame] | 39 | #include "cpu-8815.h" |
Linus Walleij | ba327b1 | 2010-05-26 07:38:54 +0100 | [diff] [blame] | 40 | |
Linus Walleij | 056c78d | 2012-01-09 11:42:39 +0100 | [diff] [blame] | 41 | /* The 8815 has 4 GPIO blocks, let's register them immediately */ |
| 42 | static resource_size_t __initdata cpu8815_gpio_base[] = { |
| 43 | NOMADIK_GPIO0_BASE, |
| 44 | NOMADIK_GPIO1_BASE, |
| 45 | NOMADIK_GPIO2_BASE, |
| 46 | NOMADIK_GPIO3_BASE, |
| 47 | }; |
| 48 | |
| 49 | static struct platform_device * |
| 50 | cpu8815_add_gpio(int id, resource_size_t addr, int irq, |
| 51 | struct nmk_gpio_platform_data *pdata) |
| 52 | { |
| 53 | struct resource resources[] = { |
| 54 | { |
| 55 | .start = addr, |
| 56 | .end = addr + 127, |
| 57 | .flags = IORESOURCE_MEM, |
| 58 | }, |
| 59 | { |
| 60 | .start = irq, |
| 61 | .end = irq, |
| 62 | .flags = IORESOURCE_IRQ, |
| 63 | } |
| 64 | }; |
| 65 | |
| 66 | return platform_device_register_resndata(NULL, "gpio", id, |
| 67 | resources, ARRAY_SIZE(resources), |
| 68 | pdata, sizeof(*pdata)); |
| 69 | } |
| 70 | |
| 71 | void cpu8815_add_gpios(resource_size_t *base, int num, int irq, |
| 72 | struct nmk_gpio_platform_data *pdata) |
| 73 | { |
| 74 | int first = 0; |
| 75 | int i; |
| 76 | |
| 77 | for (i = 0; i < num; i++, first += 32, irq++) { |
| 78 | pdata->first_gpio = first; |
| 79 | pdata->first_irq = NOMADIK_GPIO_TO_IRQ(first); |
| 80 | pdata->num_gpio = 32; |
| 81 | |
| 82 | cpu8815_add_gpio(i, base[i], irq, pdata); |
| 83 | } |
| 84 | } |
| 85 | |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 86 | static int __init cpu8815_init(void) |
| 87 | { |
Linus Walleij | 056c78d | 2012-01-09 11:42:39 +0100 | [diff] [blame] | 88 | struct nmk_gpio_platform_data pdata = { |
| 89 | /* No custom data yet */ |
| 90 | }; |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 91 | |
Linus Walleij | 056c78d | 2012-01-09 11:42:39 +0100 | [diff] [blame] | 92 | cpu8815_add_gpios(cpu8815_gpio_base, ARRAY_SIZE(cpu8815_gpio_base), |
| 93 | IRQ_GPIO0, &pdata); |
Linus Walleij | 7c77852 | 2012-01-09 12:40:02 +0100 | [diff] [blame^] | 94 | amba_apb_device_add(NULL, "rng", NOMADIK_RNG_BASE, SZ_4K, 0, 0, NULL, 0); |
Alessandro Rubini | 2ec1d35 | 2009-07-02 15:29:12 +0100 | [diff] [blame] | 95 | return 0; |
| 96 | } |
| 97 | arch_initcall(cpu8815_init); |
| 98 | |
Alessandro Rubini | 28ad94e | 2009-07-02 19:06:47 +0100 | [diff] [blame] | 99 | /* All SoC devices live in the same area (see hardware.h) */ |
| 100 | static struct map_desc nomadik_io_desc[] __initdata = { |
| 101 | { |
| 102 | .virtual = NOMADIK_IO_VIRTUAL, |
| 103 | .pfn = __phys_to_pfn(NOMADIK_IO_PHYSICAL), |
| 104 | .length = NOMADIK_IO_SIZE, |
| 105 | .type = MT_DEVICE, |
| 106 | } |
| 107 | /* static ram and secured ram may be added later */ |
| 108 | }; |
| 109 | |
| 110 | void __init cpu8815_map_io(void) |
| 111 | { |
| 112 | iotable_init(nomadik_io_desc, ARRAY_SIZE(nomadik_io_desc)); |
| 113 | } |
| 114 | |
| 115 | void __init cpu8815_init_irq(void) |
| 116 | { |
| 117 | /* This modified VIC cell has two register blocks, at 0 and 0x20 */ |
| 118 | vic_init(io_p2v(NOMADIK_IC_BASE + 0x00), IRQ_VIC_START + 0, ~0, 0); |
| 119 | vic_init(io_p2v(NOMADIK_IC_BASE + 0x20), IRQ_VIC_START + 32, ~0, 0); |
Linus Walleij | ba327b1 | 2010-05-26 07:38:54 +0100 | [diff] [blame] | 120 | |
| 121 | /* |
| 122 | * Init clocks here so that they are available for system timer |
| 123 | * initialization. |
| 124 | */ |
| 125 | clk_init(); |
Alessandro Rubini | 28ad94e | 2009-07-02 19:06:47 +0100 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | /* |
| 129 | * This function is called from the board init ("init_machine"). |
Alessandro Rubini | 28ad94e | 2009-07-02 19:06:47 +0100 | [diff] [blame] | 130 | */ |
| 131 | void __init cpu8815_platform_init(void) |
| 132 | { |
Alessandro Rubini | 0b260fd | 2009-07-02 15:29:43 +0100 | [diff] [blame] | 133 | #ifdef CONFIG_CACHE_L2X0 |
| 134 | /* At full speed latency must be >=2, so 0x249 in low bits */ |
| 135 | l2x0_init(io_p2v(NOMADIK_L2CC_BASE), 0x00730249, 0xfe000fff); |
| 136 | #endif |
Alessandro Rubini | 28ad94e | 2009-07-02 19:06:47 +0100 | [diff] [blame] | 137 | return; |
| 138 | } |
Russell King | 35b47a405 | 2011-11-28 10:48:02 +0000 | [diff] [blame] | 139 | |
| 140 | void cpu8815_restart(char mode, const char *cmd) |
| 141 | { |
| 142 | void __iomem *src_rstsr = io_p2v(NOMADIK_SRC_BASE + 0x18); |
| 143 | |
| 144 | /* FIXME: use egpio when implemented */ |
| 145 | |
| 146 | /* Write anything to Reset status register */ |
| 147 | writel(1, src_rstsr); |
| 148 | } |