Alessandro Rubini | 28ad94e | 2009-07-02 19:06:47 +0100 | [diff] [blame] | 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> |
Alessandro Rubini | 725b1f9 | 2009-07-02 15:29:32 +0100 | [diff] [blame] | 17 | #include <linux/interrupt.h> |
| 18 | #include <linux/gpio.h> |
Alessandro Rubini | 28ad94e | 2009-07-02 19:06:47 +0100 | [diff] [blame] | 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 | |
Alessandro Rubini | 725b1f9 | 2009-07-02 15:29:32 +0100 | [diff] [blame] | 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 | |
Alessandro Rubini | 28ad94e | 2009-07-02 19:06:47 +0100 | [diff] [blame] | 83 | static struct platform_device *nhk8815_platform_devices[] __initdata = { |
Alessandro Rubini | 725b1f9 | 2009-07-02 15:29:32 +0100 | [diff] [blame] | 84 | &nhk8815_eth_device, |
| 85 | /* will add more devices */ |
Alessandro Rubini | 28ad94e | 2009-07-02 19:06:47 +0100 | [diff] [blame] | 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 |