Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008-2009 ST-Ericsson |
| 3 | * |
| 4 | * Author: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com> |
| 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 | */ |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/interrupt.h> |
| 14 | #include <linux/platform_device.h> |
| 15 | #include <linux/io.h> |
| 16 | #include <linux/amba/bus.h> |
| 17 | #include <linux/amba/pl022.h> |
| 18 | #include <linux/spi/spi.h> |
| 19 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 20 | #include <asm/mach-types.h> |
| 21 | #include <asm/mach/arch.h> |
| 22 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 23 | #include <plat/i2c.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 24 | |
| 25 | #include <mach/hardware.h> |
| 26 | #include <mach/setup.h> |
| 27 | |
| 28 | #define __MEM_4K_RESOURCE(x) \ |
| 29 | .res = {.start = (x), .end = (x) + SZ_4K - 1, .flags = IORESOURCE_MEM} |
| 30 | |
| 31 | /* These are active devices on this board */ |
| 32 | static struct amba_device uart0_device = { |
| 33 | .dev = { .init_name = "uart0" }, |
| 34 | __MEM_4K_RESOURCE(U8500_UART0_BASE), |
| 35 | .irq = {IRQ_UART0, NO_IRQ}, |
| 36 | }; |
| 37 | |
| 38 | static struct amba_device uart1_device = { |
| 39 | .dev = { .init_name = "uart1" }, |
| 40 | __MEM_4K_RESOURCE(U8500_UART1_BASE), |
| 41 | .irq = {IRQ_UART1, NO_IRQ}, |
| 42 | }; |
| 43 | |
| 44 | static struct amba_device uart2_device = { |
| 45 | .dev = { .init_name = "uart2" }, |
| 46 | __MEM_4K_RESOURCE(U8500_UART2_BASE), |
| 47 | .irq = {IRQ_UART2, NO_IRQ}, |
| 48 | }; |
| 49 | |
| 50 | static void ab4500_spi_cs_control(u32 command) |
| 51 | { |
| 52 | /* set the FRM signal, which is CS - TODO */ |
| 53 | } |
| 54 | |
| 55 | struct pl022_config_chip ab4500_chip_info = { |
| 56 | .lbm = LOOPBACK_DISABLED, |
| 57 | .com_mode = INTERRUPT_TRANSFER, |
| 58 | .iface = SSP_INTERFACE_MOTOROLA_SPI, |
| 59 | /* we can act as master only */ |
| 60 | .hierarchy = SSP_MASTER, |
| 61 | .slave_tx_disable = 0, |
| 62 | .endian_rx = SSP_RX_MSB, |
| 63 | .endian_tx = SSP_TX_MSB, |
| 64 | .data_size = SSP_DATA_BITS_24, |
| 65 | .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM, |
| 66 | .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC, |
| 67 | .clk_phase = SSP_CLK_SECOND_EDGE, |
| 68 | .clk_pol = SSP_CLK_POL_IDLE_HIGH, |
| 69 | .cs_control = ab4500_spi_cs_control, |
| 70 | }; |
| 71 | |
| 72 | static struct spi_board_info u8500_spi_devices[] = { |
| 73 | { |
| 74 | .modalias = "ab4500", |
| 75 | .controller_data = &ab4500_chip_info, |
| 76 | .max_speed_hz = 12000000, |
| 77 | .bus_num = 0, |
| 78 | .chip_select = 0, |
| 79 | .mode = SPI_MODE_0, |
| 80 | .irq = IRQ_AB4500, |
| 81 | }, |
| 82 | }; |
| 83 | |
| 84 | static struct pl022_ssp_controller ssp0_platform_data = { |
| 85 | .bus_id = 0, |
| 86 | /* pl022 not yet supports dma */ |
| 87 | .enable_dma = 0, |
| 88 | /* on this platform, gpio 31,142,144,214 & |
| 89 | * 224 are connected as chip selects |
| 90 | */ |
| 91 | .num_chipselect = 5, |
| 92 | }; |
| 93 | |
| 94 | static struct amba_device pl022_device = { |
| 95 | .dev = { |
| 96 | .coherent_dma_mask = ~0, |
Rabin Vincent | 1df20af | 2010-03-01 05:07:47 +0100 | [diff] [blame^] | 97 | .init_name = "ssp0", |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 98 | .platform_data = &ssp0_platform_data, |
| 99 | }, |
| 100 | .res = { |
| 101 | .start = U8500_SSP0_BASE, |
| 102 | .end = U8500_SSP0_BASE + SZ_4K - 1, |
| 103 | .flags = IORESOURCE_MEM, |
| 104 | }, |
| 105 | .irq = {IRQ_SSP0, NO_IRQ }, |
| 106 | /* ST-Ericsson modified id */ |
| 107 | .periphid = SSP_PER_ID, |
| 108 | }; |
| 109 | |
Linus Walleij | 8e58ed3 | 2010-02-04 12:50:58 +0100 | [diff] [blame] | 110 | static struct amba_device pl031_device = { |
| 111 | .dev = { |
| 112 | .init_name = "pl031", |
| 113 | }, |
| 114 | .res = { |
| 115 | .start = U8500_RTC_BASE, |
| 116 | .end = U8500_RTC_BASE + SZ_4K - 1, |
| 117 | .flags = IORESOURCE_MEM, |
| 118 | }, |
| 119 | .irq = {IRQ_RTC_RTT, NO_IRQ}, |
| 120 | }; |
| 121 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 122 | #define U8500_I2C_RESOURCES(id, size) \ |
| 123 | static struct resource u8500_i2c_resources_##id[] = { \ |
| 124 | [0] = { \ |
| 125 | .start = U8500_I2C##id##_BASE, \ |
| 126 | .end = U8500_I2C##id##_BASE + size - 1, \ |
| 127 | .flags = IORESOURCE_MEM, \ |
| 128 | }, \ |
| 129 | [1] = { \ |
| 130 | .start = IRQ_I2C##id, \ |
| 131 | .end = IRQ_I2C##id, \ |
| 132 | .flags = IORESOURCE_IRQ \ |
| 133 | } \ |
| 134 | } |
| 135 | |
| 136 | U8500_I2C_RESOURCES(0, SZ_4K); |
| 137 | U8500_I2C_RESOURCES(1, SZ_4K); |
| 138 | U8500_I2C_RESOURCES(2, SZ_4K); |
| 139 | U8500_I2C_RESOURCES(3, SZ_4K); |
| 140 | |
| 141 | #define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \ |
| 142 | static struct nmk_i2c_controller u8500_i2c_##id = { \ |
| 143 | /* \ |
| 144 | * slave data setup time, which is \ |
| 145 | * 250 ns,100ns,10ns which is 14,6,2 \ |
| 146 | * respectively for a 48 Mhz \ |
| 147 | * i2c clock \ |
| 148 | */ \ |
| 149 | .slsu = _slsu, \ |
| 150 | /* Tx FIFO threshold */ \ |
| 151 | .tft = _tft, \ |
| 152 | /* Rx FIFO threshold */ \ |
| 153 | .rft = _rft, \ |
| 154 | /* std. mode operation */ \ |
| 155 | .clk_freq = clk, \ |
| 156 | .sm = _sm, \ |
| 157 | } |
| 158 | |
| 159 | /* |
| 160 | * The board uses 4 i2c controllers, initialize all of |
| 161 | * them with slave data setup time of 250 ns, |
| 162 | * Tx & Rx FIFO threshold values as 1 and standard |
| 163 | * mode of operation |
| 164 | */ |
| 165 | U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 166 | U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 167 | U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 168 | U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 169 | |
| 170 | #define U8500_I2C_PDEVICE(cid) \ |
| 171 | static struct platform_device i2c_controller##cid = { \ |
| 172 | .name = "nmk-i2c", \ |
| 173 | .id = cid, \ |
| 174 | .num_resources = 2, \ |
| 175 | .resource = u8500_i2c_resources_##cid, \ |
| 176 | .dev = { \ |
| 177 | .platform_data = &u8500_i2c_##cid \ |
| 178 | } \ |
| 179 | } |
| 180 | |
| 181 | U8500_I2C_PDEVICE(0); |
| 182 | U8500_I2C_PDEVICE(1); |
| 183 | U8500_I2C_PDEVICE(2); |
| 184 | U8500_I2C_PDEVICE(3); |
| 185 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 186 | static struct amba_device *amba_devs[] __initdata = { |
| 187 | &uart0_device, |
| 188 | &uart1_device, |
| 189 | &uart2_device, |
| 190 | &pl022_device, |
Linus Walleij | 8e58ed3 | 2010-02-04 12:50:58 +0100 | [diff] [blame] | 191 | &pl031_device, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 192 | }; |
| 193 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 194 | /* add any platform devices here - TODO */ |
| 195 | static struct platform_device *platform_devs[] __initdata = { |
| 196 | &i2c_controller0, |
| 197 | &i2c_controller1, |
| 198 | &i2c_controller2, |
| 199 | &i2c_controller3, |
| 200 | }; |
| 201 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 202 | static void __init u8500_init_machine(void) |
| 203 | { |
| 204 | int i; |
| 205 | |
| 206 | /* Register the active AMBA devices on this board */ |
| 207 | for (i = 0; i < ARRAY_SIZE(amba_devs); i++) |
| 208 | amba_device_register(amba_devs[i], &iomem_resource); |
| 209 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 210 | platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs)); |
| 211 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 212 | spi_register_board_info(u8500_spi_devices, |
| 213 | ARRAY_SIZE(u8500_spi_devices)); |
| 214 | |
| 215 | u8500_init_devices(); |
| 216 | } |
| 217 | |
| 218 | MACHINE_START(U8500, "ST-Ericsson MOP500 platform") |
| 219 | /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */ |
| 220 | .phys_io = U8500_UART2_BASE, |
| 221 | .io_pg_offst = (IO_ADDRESS(U8500_UART2_BASE) >> 18) & 0xfffc, |
| 222 | .boot_params = 0x100, |
| 223 | .map_io = u8500_map_io, |
| 224 | .init_irq = u8500_init_irq, |
| 225 | /* we re-use nomadik timer here */ |
| 226 | .timer = &u8500_timer, |
| 227 | .init_machine = u8500_init_machine, |
| 228 | MACHINE_END |