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