128ad94ecSAlessandro Rubini /* 228ad94ecSAlessandro Rubini * Copyright STMicroelectronics, 2007. 328ad94ecSAlessandro Rubini * 428ad94ecSAlessandro Rubini * This program is free software; you can redistribute it and/or modify 528ad94ecSAlessandro Rubini * it under the terms of the GNU General Public License as published by 628ad94ecSAlessandro Rubini * the Free Software Foundation; either version 2 of the License, or 728ad94ecSAlessandro Rubini * (at your option) any later version. 828ad94ecSAlessandro Rubini * 928ad94ecSAlessandro Rubini * This program is distributed in the hope that it will be useful, 1028ad94ecSAlessandro Rubini * but WITHOUT ANY WARRANTY; without even the implied warranty of 1128ad94ecSAlessandro Rubini * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1228ad94ecSAlessandro Rubini * GNU General Public License for more details. 1328ad94ecSAlessandro Rubini * 1428ad94ecSAlessandro Rubini * You should have received a copy of the GNU General Public License 1528ad94ecSAlessandro Rubini * along with this program; if not, write to the Free Software 1628ad94ecSAlessandro Rubini * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 1728ad94ecSAlessandro Rubini */ 1828ad94ecSAlessandro Rubini 1928ad94ecSAlessandro Rubini #include <linux/types.h> 2028ad94ecSAlessandro Rubini #include <linux/init.h> 2128ad94ecSAlessandro Rubini #include <linux/device.h> 222ec1d359SAlessandro Rubini #include <linux/amba/bus.h> 233e3c62caSRabin Vincent #include <linux/platform_device.h> 242ec1d359SAlessandro Rubini #include <linux/gpio.h> 2528ad94ecSAlessandro Rubini 2628ad94ecSAlessandro Rubini #include <mach/hardware.h> 2728ad94ecSAlessandro Rubini #include <mach/irqs.h> 2828ad94ecSAlessandro Rubini #include <asm/mach/map.h> 2928ad94ecSAlessandro Rubini #include <asm/hardware/vic.h> 3028ad94ecSAlessandro Rubini 310b260fd4SAlessandro Rubini #include <asm/cacheflush.h> 320b260fd4SAlessandro Rubini #include <asm/hardware/cache-l2x0.h> 330b260fd4SAlessandro Rubini 343e3c62caSRabin Vincent #define __MEM_4K_RESOURCE(x) \ 353e3c62caSRabin Vincent .res = {.start = (x), .end = (x) + SZ_4K - 1, .flags = IORESOURCE_MEM} 363e3c62caSRabin Vincent 372ec1d359SAlessandro Rubini /* The 8815 has 4 GPIO blocks, let's register them immediately */ 383e3c62caSRabin Vincent 393e3c62caSRabin Vincent #define GPIO_RESOURCE(block) \ 403e3c62caSRabin Vincent { \ 413e3c62caSRabin Vincent .start = NOMADIK_GPIO##block##_BASE, \ 423e3c62caSRabin Vincent .end = NOMADIK_GPIO##block##_BASE + SZ_4K - 1, \ 433e3c62caSRabin Vincent .flags = IORESOURCE_MEM, \ 443e3c62caSRabin Vincent }, \ 453e3c62caSRabin Vincent { \ 463e3c62caSRabin Vincent .start = IRQ_GPIO##block, \ 473e3c62caSRabin Vincent .end = IRQ_GPIO##block, \ 483e3c62caSRabin Vincent .flags = IORESOURCE_IRQ, \ 493e3c62caSRabin Vincent } 503e3c62caSRabin Vincent 513e3c62caSRabin Vincent #define GPIO_DEVICE(block) \ 523e3c62caSRabin Vincent { \ 533e3c62caSRabin Vincent .name = "gpio", \ 543e3c62caSRabin Vincent .id = block, \ 553e3c62caSRabin Vincent .num_resources = 2, \ 563e3c62caSRabin Vincent .resource = &cpu8815_gpio_resources[block * 2], \ 573e3c62caSRabin Vincent .dev = { \ 583e3c62caSRabin Vincent .platform_data = &cpu8815_gpio[block], \ 593e3c62caSRabin Vincent }, \ 603e3c62caSRabin Vincent } 613e3c62caSRabin Vincent 622ec1d359SAlessandro Rubini static struct nmk_gpio_platform_data cpu8815_gpio[] = { 632ec1d359SAlessandro Rubini { 642ec1d359SAlessandro Rubini .name = "GPIO-0-31", 652ec1d359SAlessandro Rubini .first_gpio = 0, 662ec1d359SAlessandro Rubini .first_irq = NOMADIK_GPIO_TO_IRQ(0), 672ec1d359SAlessandro Rubini }, { 682ec1d359SAlessandro Rubini .name = "GPIO-32-63", 692ec1d359SAlessandro Rubini .first_gpio = 32, 702ec1d359SAlessandro Rubini .first_irq = NOMADIK_GPIO_TO_IRQ(32), 712ec1d359SAlessandro Rubini }, { 722ec1d359SAlessandro Rubini .name = "GPIO-64-95", 732ec1d359SAlessandro Rubini .first_gpio = 64, 742ec1d359SAlessandro Rubini .first_irq = NOMADIK_GPIO_TO_IRQ(64), 752ec1d359SAlessandro Rubini }, { 762ec1d359SAlessandro Rubini .name = "GPIO-96-127", /* 124..127 not routed to pin */ 772ec1d359SAlessandro Rubini .first_gpio = 96, 782ec1d359SAlessandro Rubini .first_irq = NOMADIK_GPIO_TO_IRQ(96), 792ec1d359SAlessandro Rubini } 802ec1d359SAlessandro Rubini }; 812ec1d359SAlessandro Rubini 823e3c62caSRabin Vincent static struct resource cpu8815_gpio_resources[] = { 833e3c62caSRabin Vincent GPIO_RESOURCE(0), 843e3c62caSRabin Vincent GPIO_RESOURCE(1), 853e3c62caSRabin Vincent GPIO_RESOURCE(2), 863e3c62caSRabin Vincent GPIO_RESOURCE(3), 873e3c62caSRabin Vincent }; 882ec1d359SAlessandro Rubini 893e3c62caSRabin Vincent static struct platform_device cpu8815_platform_gpio[] = { 903e3c62caSRabin Vincent GPIO_DEVICE(0), 913e3c62caSRabin Vincent GPIO_DEVICE(1), 923e3c62caSRabin Vincent GPIO_DEVICE(2), 933e3c62caSRabin Vincent GPIO_DEVICE(3), 942ec1d359SAlessandro Rubini }; 952ec1d359SAlessandro Rubini 96d2392ba0SAlessandro Rubini static struct amba_device cpu8815_amba_rng = { 97d2392ba0SAlessandro Rubini .dev = { 98d2392ba0SAlessandro Rubini .init_name = "rng", 99d2392ba0SAlessandro Rubini }, 100d2392ba0SAlessandro Rubini __MEM_4K_RESOURCE(NOMADIK_RNG_BASE), 101d2392ba0SAlessandro Rubini }; 102d2392ba0SAlessandro Rubini 1033e3c62caSRabin Vincent static struct platform_device *platform_devs[] __initdata = { 1043e3c62caSRabin Vincent cpu8815_platform_gpio + 0, 1053e3c62caSRabin Vincent cpu8815_platform_gpio + 1, 1063e3c62caSRabin Vincent cpu8815_platform_gpio + 2, 1073e3c62caSRabin Vincent cpu8815_platform_gpio + 3, 1083e3c62caSRabin Vincent }; 1093e3c62caSRabin Vincent 1102ec1d359SAlessandro Rubini static struct amba_device *amba_devs[] __initdata = { 111d2392ba0SAlessandro Rubini &cpu8815_amba_rng 1122ec1d359SAlessandro Rubini }; 1132ec1d359SAlessandro Rubini 1142ec1d359SAlessandro Rubini static int __init cpu8815_init(void) 1152ec1d359SAlessandro Rubini { 1162ec1d359SAlessandro Rubini int i; 1172ec1d359SAlessandro Rubini 1183e3c62caSRabin Vincent platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs)); 1192ec1d359SAlessandro Rubini for (i = 0; i < ARRAY_SIZE(amba_devs); i++) 1202ec1d359SAlessandro Rubini amba_device_register(amba_devs[i], &iomem_resource); 1212ec1d359SAlessandro Rubini return 0; 1222ec1d359SAlessandro Rubini } 1232ec1d359SAlessandro Rubini arch_initcall(cpu8815_init); 1242ec1d359SAlessandro Rubini 12528ad94ecSAlessandro Rubini /* All SoC devices live in the same area (see hardware.h) */ 12628ad94ecSAlessandro Rubini static struct map_desc nomadik_io_desc[] __initdata = { 12728ad94ecSAlessandro Rubini { 12828ad94ecSAlessandro Rubini .virtual = NOMADIK_IO_VIRTUAL, 12928ad94ecSAlessandro Rubini .pfn = __phys_to_pfn(NOMADIK_IO_PHYSICAL), 13028ad94ecSAlessandro Rubini .length = NOMADIK_IO_SIZE, 13128ad94ecSAlessandro Rubini .type = MT_DEVICE, 13228ad94ecSAlessandro Rubini } 13328ad94ecSAlessandro Rubini /* static ram and secured ram may be added later */ 13428ad94ecSAlessandro Rubini }; 13528ad94ecSAlessandro Rubini 13628ad94ecSAlessandro Rubini void __init cpu8815_map_io(void) 13728ad94ecSAlessandro Rubini { 13828ad94ecSAlessandro Rubini iotable_init(nomadik_io_desc, ARRAY_SIZE(nomadik_io_desc)); 13928ad94ecSAlessandro Rubini } 14028ad94ecSAlessandro Rubini 14128ad94ecSAlessandro Rubini void __init cpu8815_init_irq(void) 14228ad94ecSAlessandro Rubini { 14328ad94ecSAlessandro Rubini /* This modified VIC cell has two register blocks, at 0 and 0x20 */ 14428ad94ecSAlessandro Rubini vic_init(io_p2v(NOMADIK_IC_BASE + 0x00), IRQ_VIC_START + 0, ~0, 0); 14528ad94ecSAlessandro Rubini vic_init(io_p2v(NOMADIK_IC_BASE + 0x20), IRQ_VIC_START + 32, ~0, 0); 14628ad94ecSAlessandro Rubini } 14728ad94ecSAlessandro Rubini 14828ad94ecSAlessandro Rubini /* 14928ad94ecSAlessandro Rubini * This function is called from the board init ("init_machine"). 15028ad94ecSAlessandro Rubini */ 15128ad94ecSAlessandro Rubini void __init cpu8815_platform_init(void) 15228ad94ecSAlessandro Rubini { 1530b260fd4SAlessandro Rubini #ifdef CONFIG_CACHE_L2X0 1540b260fd4SAlessandro Rubini /* At full speed latency must be >=2, so 0x249 in low bits */ 1550b260fd4SAlessandro Rubini l2x0_init(io_p2v(NOMADIK_L2CC_BASE), 0x00730249, 0xfe000fff); 1560b260fd4SAlessandro Rubini #endif 15728ad94ecSAlessandro Rubini return; 15828ad94ecSAlessandro Rubini } 159