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> |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 16 | #include <linux/gpio.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 17 | #include <linux/amba/bus.h> |
| 18 | #include <linux/amba/pl022.h> |
| 19 | #include <linux/spi/spi.h> |
Rabin Vincent | 39ae702 | 2010-07-26 11:12:15 +0100 | [diff] [blame] | 20 | #include <linux/mfd/ab8500.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 21 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 22 | #include <asm/mach-types.h> |
| 23 | #include <asm/mach/arch.h> |
| 24 | |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 25 | #include <plat/pincfg.h> |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 26 | #include <plat/i2c.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 27 | |
| 28 | #include <mach/hardware.h> |
| 29 | #include <mach/setup.h> |
Rabin Vincent | 9e4e7fe | 2010-05-03 08:03:52 +0100 | [diff] [blame] | 30 | #include <mach/devices.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 31 | |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 32 | #include "pins-db8500.h" |
Hanumath Prasad | 008f8a2 | 2010-08-19 12:06:32 +0100 | [diff] [blame^] | 33 | #include "board-mop500.h" |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 34 | |
| 35 | static pin_cfg_t mop500_pins[] = { |
| 36 | /* SSP0 */ |
| 37 | GPIO143_SSP0_CLK, |
| 38 | GPIO144_SSP0_FRM, |
| 39 | GPIO145_SSP0_RXD, |
| 40 | GPIO146_SSP0_TXD, |
| 41 | |
| 42 | /* I2C */ |
| 43 | GPIO147_I2C0_SCL, |
| 44 | GPIO148_I2C0_SDA, |
| 45 | GPIO16_I2C1_SCL, |
| 46 | GPIO17_I2C1_SDA, |
| 47 | GPIO10_I2C2_SDA, |
| 48 | GPIO11_I2C2_SCL, |
| 49 | GPIO229_I2C3_SDA, |
| 50 | GPIO230_I2C3_SCL, |
| 51 | }; |
| 52 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 53 | static void ab4500_spi_cs_control(u32 command) |
| 54 | { |
| 55 | /* set the FRM signal, which is CS - TODO */ |
| 56 | } |
| 57 | |
| 58 | struct pl022_config_chip ab4500_chip_info = { |
| 59 | .lbm = LOOPBACK_DISABLED, |
| 60 | .com_mode = INTERRUPT_TRANSFER, |
| 61 | .iface = SSP_INTERFACE_MOTOROLA_SPI, |
| 62 | /* we can act as master only */ |
| 63 | .hierarchy = SSP_MASTER, |
| 64 | .slave_tx_disable = 0, |
| 65 | .endian_rx = SSP_RX_MSB, |
| 66 | .endian_tx = SSP_TX_MSB, |
| 67 | .data_size = SSP_DATA_BITS_24, |
| 68 | .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM, |
| 69 | .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC, |
| 70 | .clk_phase = SSP_CLK_SECOND_EDGE, |
| 71 | .clk_pol = SSP_CLK_POL_IDLE_HIGH, |
| 72 | .cs_control = ab4500_spi_cs_control, |
| 73 | }; |
| 74 | |
Rabin Vincent | 39ae702 | 2010-07-26 11:12:15 +0100 | [diff] [blame] | 75 | static struct ab8500_platform_data ab8500_platdata = { |
| 76 | .irq_base = MOP500_AB8500_IRQ_BASE, |
| 77 | }; |
| 78 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 79 | static struct spi_board_info u8500_spi_devices[] = { |
| 80 | { |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 81 | .modalias = "ab8500", |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 82 | .controller_data = &ab4500_chip_info, |
Rabin Vincent | 39ae702 | 2010-07-26 11:12:15 +0100 | [diff] [blame] | 83 | .platform_data = &ab8500_platdata, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 84 | .max_speed_hz = 12000000, |
| 85 | .bus_num = 0, |
| 86 | .chip_select = 0, |
| 87 | .mode = SPI_MODE_0, |
Rabin Vincent | 6055930 | 2010-07-26 11:09:27 +0100 | [diff] [blame] | 88 | .irq = IRQ_DB8500_AB8500, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 89 | }, |
| 90 | }; |
| 91 | |
| 92 | static struct pl022_ssp_controller ssp0_platform_data = { |
| 93 | .bus_id = 0, |
| 94 | /* pl022 not yet supports dma */ |
| 95 | .enable_dma = 0, |
| 96 | /* on this platform, gpio 31,142,144,214 & |
| 97 | * 224 are connected as chip selects |
| 98 | */ |
| 99 | .num_chipselect = 5, |
| 100 | }; |
| 101 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 102 | #define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \ |
Rabin Vincent | f9faf23 | 2010-05-03 08:24:37 +0100 | [diff] [blame] | 103 | static struct nmk_i2c_controller u8500_i2c##id##_data = { \ |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 104 | /* \ |
| 105 | * slave data setup time, which is \ |
| 106 | * 250 ns,100ns,10ns which is 14,6,2 \ |
| 107 | * respectively for a 48 Mhz \ |
| 108 | * i2c clock \ |
| 109 | */ \ |
| 110 | .slsu = _slsu, \ |
| 111 | /* Tx FIFO threshold */ \ |
| 112 | .tft = _tft, \ |
| 113 | /* Rx FIFO threshold */ \ |
| 114 | .rft = _rft, \ |
| 115 | /* std. mode operation */ \ |
| 116 | .clk_freq = clk, \ |
| 117 | .sm = _sm, \ |
| 118 | } |
| 119 | |
| 120 | /* |
| 121 | * The board uses 4 i2c controllers, initialize all of |
| 122 | * them with slave data setup time of 250 ns, |
| 123 | * Tx & Rx FIFO threshold values as 1 and standard |
| 124 | * mode of operation |
| 125 | */ |
| 126 | U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 127 | U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 128 | U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 129 | U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 130 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 131 | static struct amba_device *amba_devs[] __initdata = { |
Rabin Vincent | 4b27aa4 | 2010-05-03 08:18:38 +0100 | [diff] [blame] | 132 | &ux500_uart0_device, |
| 133 | &ux500_uart1_device, |
| 134 | &ux500_uart2_device, |
Rabin Vincent | 9e4e7fe | 2010-05-03 08:03:52 +0100 | [diff] [blame] | 135 | &u8500_ssp0_device, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 136 | }; |
| 137 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 138 | /* add any platform devices here - TODO */ |
| 139 | static struct platform_device *platform_devs[] __initdata = { |
Rabin Vincent | f9faf23 | 2010-05-03 08:24:37 +0100 | [diff] [blame] | 140 | &u8500_i2c0_device, |
| 141 | &ux500_i2c1_device, |
| 142 | &ux500_i2c2_device, |
| 143 | &ux500_i2c3_device, |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 144 | }; |
| 145 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 146 | static void __init u8500_init_machine(void) |
| 147 | { |
| 148 | int i; |
| 149 | |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 150 | u8500_init_devices(); |
| 151 | |
| 152 | nmk_config_pins(mop500_pins, ARRAY_SIZE(mop500_pins)); |
| 153 | |
Rabin Vincent | f9faf23 | 2010-05-03 08:24:37 +0100 | [diff] [blame] | 154 | u8500_i2c0_device.dev.platform_data = &u8500_i2c0_data; |
| 155 | ux500_i2c1_device.dev.platform_data = &u8500_i2c1_data; |
| 156 | ux500_i2c2_device.dev.platform_data = &u8500_i2c2_data; |
| 157 | ux500_i2c3_device.dev.platform_data = &u8500_i2c3_data; |
| 158 | |
Rabin Vincent | 9e4e7fe | 2010-05-03 08:03:52 +0100 | [diff] [blame] | 159 | u8500_ssp0_device.dev.platform_data = &ssp0_platform_data; |
| 160 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 161 | /* Register the active AMBA devices on this board */ |
| 162 | for (i = 0; i < ARRAY_SIZE(amba_devs); i++) |
| 163 | amba_device_register(amba_devs[i], &iomem_resource); |
| 164 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 165 | platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs)); |
| 166 | |
Hanumath Prasad | 008f8a2 | 2010-08-19 12:06:32 +0100 | [diff] [blame^] | 167 | mop500_sdi_init(); |
| 168 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 169 | spi_register_board_info(u8500_spi_devices, |
| 170 | ARRAY_SIZE(u8500_spi_devices)); |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 171 | } |
| 172 | |
| 173 | MACHINE_START(U8500, "ST-Ericsson MOP500 platform") |
| 174 | /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */ |
| 175 | .phys_io = U8500_UART2_BASE, |
| 176 | .io_pg_offst = (IO_ADDRESS(U8500_UART2_BASE) >> 18) & 0xfffc, |
| 177 | .boot_params = 0x100, |
| 178 | .map_io = u8500_map_io, |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 179 | .init_irq = ux500_init_irq, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 180 | /* we re-use nomadik timer here */ |
Rabin Vincent | 41ac329 | 2010-05-03 08:28:05 +0100 | [diff] [blame] | 181 | .timer = &ux500_timer, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 182 | .init_machine = u8500_init_machine, |
| 183 | MACHINE_END |