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