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> 232ec1d359SAlessandro Rubini #include <linux/gpio.h> 2428ad94ecSAlessandro Rubini 2528ad94ecSAlessandro Rubini #include <mach/hardware.h> 2628ad94ecSAlessandro Rubini #include <mach/irqs.h> 2728ad94ecSAlessandro Rubini #include <asm/mach/map.h> 2828ad94ecSAlessandro Rubini #include <asm/hardware/vic.h> 2928ad94ecSAlessandro Rubini 302ec1d359SAlessandro Rubini /* The 8815 has 4 GPIO blocks, let's register them immediately */ 312ec1d359SAlessandro Rubini static struct nmk_gpio_platform_data cpu8815_gpio[] = { 322ec1d359SAlessandro Rubini { 332ec1d359SAlessandro Rubini .name = "GPIO-0-31", 342ec1d359SAlessandro Rubini .first_gpio = 0, 352ec1d359SAlessandro Rubini .first_irq = NOMADIK_GPIO_TO_IRQ(0), 362ec1d359SAlessandro Rubini .parent_irq = IRQ_GPIO0, 372ec1d359SAlessandro Rubini }, { 382ec1d359SAlessandro Rubini .name = "GPIO-32-63", 392ec1d359SAlessandro Rubini .first_gpio = 32, 402ec1d359SAlessandro Rubini .first_irq = NOMADIK_GPIO_TO_IRQ(32), 412ec1d359SAlessandro Rubini .parent_irq = IRQ_GPIO1, 422ec1d359SAlessandro Rubini }, { 432ec1d359SAlessandro Rubini .name = "GPIO-64-95", 442ec1d359SAlessandro Rubini .first_gpio = 64, 452ec1d359SAlessandro Rubini .first_irq = NOMADIK_GPIO_TO_IRQ(64), 462ec1d359SAlessandro Rubini .parent_irq = IRQ_GPIO2, 472ec1d359SAlessandro Rubini }, { 482ec1d359SAlessandro Rubini .name = "GPIO-96-127", /* 124..127 not routed to pin */ 492ec1d359SAlessandro Rubini .first_gpio = 96, 502ec1d359SAlessandro Rubini .first_irq = NOMADIK_GPIO_TO_IRQ(96), 512ec1d359SAlessandro Rubini .parent_irq = IRQ_GPIO3, 522ec1d359SAlessandro Rubini } 532ec1d359SAlessandro Rubini }; 542ec1d359SAlessandro Rubini 552ec1d359SAlessandro Rubini #define __MEM_4K_RESOURCE(x) \ 562ec1d359SAlessandro Rubini .res = {.start = (x), .end = (x) + SZ_4K - 1, .flags = IORESOURCE_MEM} 572ec1d359SAlessandro Rubini 582ec1d359SAlessandro Rubini static struct amba_device cpu8815_amba_gpio[] = { 592ec1d359SAlessandro Rubini { 602ec1d359SAlessandro Rubini .dev = { 612ec1d359SAlessandro Rubini .init_name = "gpio0", 622ec1d359SAlessandro Rubini .platform_data = cpu8815_gpio + 0, 632ec1d359SAlessandro Rubini }, 642ec1d359SAlessandro Rubini __MEM_4K_RESOURCE(NOMADIK_GPIO0_BASE), 652ec1d359SAlessandro Rubini }, { 662ec1d359SAlessandro Rubini .dev = { 672ec1d359SAlessandro Rubini .init_name = "gpio1", 682ec1d359SAlessandro Rubini .platform_data = cpu8815_gpio + 1, 692ec1d359SAlessandro Rubini }, 702ec1d359SAlessandro Rubini __MEM_4K_RESOURCE(NOMADIK_GPIO1_BASE), 712ec1d359SAlessandro Rubini }, { 722ec1d359SAlessandro Rubini .dev = { 732ec1d359SAlessandro Rubini .init_name = "gpio2", 742ec1d359SAlessandro Rubini .platform_data = cpu8815_gpio + 2, 752ec1d359SAlessandro Rubini }, 762ec1d359SAlessandro Rubini __MEM_4K_RESOURCE(NOMADIK_GPIO2_BASE), 772ec1d359SAlessandro Rubini }, { 782ec1d359SAlessandro Rubini .dev = { 792ec1d359SAlessandro Rubini .init_name = "gpio3", 802ec1d359SAlessandro Rubini .platform_data = cpu8815_gpio + 3, 812ec1d359SAlessandro Rubini }, 822ec1d359SAlessandro Rubini __MEM_4K_RESOURCE(NOMADIK_GPIO3_BASE), 832ec1d359SAlessandro Rubini }, 842ec1d359SAlessandro Rubini }; 852ec1d359SAlessandro Rubini 862ec1d359SAlessandro Rubini static struct amba_device *amba_devs[] __initdata = { 872ec1d359SAlessandro Rubini cpu8815_amba_gpio + 0, 882ec1d359SAlessandro Rubini cpu8815_amba_gpio + 1, 892ec1d359SAlessandro Rubini cpu8815_amba_gpio + 2, 902ec1d359SAlessandro Rubini cpu8815_amba_gpio + 3, 912ec1d359SAlessandro Rubini }; 922ec1d359SAlessandro Rubini 932ec1d359SAlessandro Rubini static int __init cpu8815_init(void) 942ec1d359SAlessandro Rubini { 952ec1d359SAlessandro Rubini int i; 962ec1d359SAlessandro Rubini 972ec1d359SAlessandro Rubini for (i = 0; i < ARRAY_SIZE(amba_devs); i++) 982ec1d359SAlessandro Rubini amba_device_register(amba_devs[i], &iomem_resource); 992ec1d359SAlessandro Rubini return 0; 1002ec1d359SAlessandro Rubini } 1012ec1d359SAlessandro Rubini arch_initcall(cpu8815_init); 1022ec1d359SAlessandro Rubini 10328ad94ecSAlessandro Rubini /* All SoC devices live in the same area (see hardware.h) */ 10428ad94ecSAlessandro Rubini static struct map_desc nomadik_io_desc[] __initdata = { 10528ad94ecSAlessandro Rubini { 10628ad94ecSAlessandro Rubini .virtual = NOMADIK_IO_VIRTUAL, 10728ad94ecSAlessandro Rubini .pfn = __phys_to_pfn(NOMADIK_IO_PHYSICAL), 10828ad94ecSAlessandro Rubini .length = NOMADIK_IO_SIZE, 10928ad94ecSAlessandro Rubini .type = MT_DEVICE, 11028ad94ecSAlessandro Rubini } 11128ad94ecSAlessandro Rubini /* static ram and secured ram may be added later */ 11228ad94ecSAlessandro Rubini }; 11328ad94ecSAlessandro Rubini 11428ad94ecSAlessandro Rubini void __init cpu8815_map_io(void) 11528ad94ecSAlessandro Rubini { 11628ad94ecSAlessandro Rubini iotable_init(nomadik_io_desc, ARRAY_SIZE(nomadik_io_desc)); 11728ad94ecSAlessandro Rubini } 11828ad94ecSAlessandro Rubini 11928ad94ecSAlessandro Rubini void __init cpu8815_init_irq(void) 12028ad94ecSAlessandro Rubini { 12128ad94ecSAlessandro Rubini /* This modified VIC cell has two register blocks, at 0 and 0x20 */ 12228ad94ecSAlessandro Rubini vic_init(io_p2v(NOMADIK_IC_BASE + 0x00), IRQ_VIC_START + 0, ~0, 0); 12328ad94ecSAlessandro Rubini vic_init(io_p2v(NOMADIK_IC_BASE + 0x20), IRQ_VIC_START + 32, ~0, 0); 12428ad94ecSAlessandro Rubini } 12528ad94ecSAlessandro Rubini 12628ad94ecSAlessandro Rubini /* 12728ad94ecSAlessandro Rubini * This function is called from the board init ("init_machine"). 12828ad94ecSAlessandro Rubini * Currently nothing is done as we can't register amba devs so early. 12928ad94ecSAlessandro Rubini */ 13028ad94ecSAlessandro Rubini void __init cpu8815_platform_init(void) 13128ad94ecSAlessandro Rubini { 13228ad94ecSAlessandro Rubini return; 13328ad94ecSAlessandro Rubini } 134