blob: 0ff4be72a8093a3989e7dcc34769a003b9ed6dd7 [file] [log] [blame]
Rabin Vincent591d8dd2010-05-03 08:46:51 +01001/*
2 * Copyright (C) ST-Ericsson SA 2010
3 *
4 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
5 * License terms: GNU General Public License (GPL) version 2
6 */
7
8#include <linux/init.h>
9#include <linux/platform_device.h>
10#include <linux/amba/bus.h>
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053011#include <linux/irq.h>
Linus Walleijb09628e2011-07-25 17:13:18 -070012#include <linux/i2c.h>
Linus Walleijee66e652011-12-02 14:16:33 +010013#include <linux/mfd/abx500/ab5500.h>
Rabin Vincent591d8dd2010-05-03 08:46:51 +010014
Marc Zyngierbbf5f382011-09-06 10:23:45 +010015#include <asm/hardware/gic.h>
Rabin Vincent591d8dd2010-05-03 08:46:51 +010016#include <asm/mach/arch.h>
17#include <asm/mach-types.h>
18
Linus Walleijb09628e2011-07-25 17:13:18 -070019#include <plat/pincfg.h>
20#include <plat/i2c.h>
Linus Walleij0f332862011-08-22 08:33:30 +010021#include <plat/gpio-nomadik.h>
Linus Walleijb09628e2011-07-25 17:13:18 -070022
Rabin Vincent591d8dd2010-05-03 08:46:51 +010023#include <mach/hardware.h>
24#include <mach/devices.h>
25#include <mach/setup.h>
26
Linus Walleijb09628e2011-07-25 17:13:18 -070027#include "pins-db5500.h"
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053028#include "devices-db5500.h"
Linus Walleijb09628e2011-07-25 17:13:18 -070029#include <linux/led-lm3530.h>
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053030
Linus Walleijb09628e2011-07-25 17:13:18 -070031/*
32 * GPIO
33 */
34
35static pin_cfg_t u5500_pins[] = {
36 /* I2C */
37 GPIO218_I2C2_SCL | PIN_INPUT_PULLUP,
38 GPIO219_I2C2_SDA | PIN_INPUT_PULLUP,
39
40 /* DISPLAY_ENABLE */
41 GPIO226_GPIO | PIN_OUTPUT_LOW,
42
43 /* Backlight Enbale */
44 GPIO224_GPIO | PIN_OUTPUT_HIGH,
45};
46/*
47 * I2C
48 */
49
50#define U5500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
51static struct nmk_i2c_controller u5500_i2c##id##_data = { \
52 /* \
53 * slave data setup time, which is \
54 * 250 ns,100ns,10ns which is 14,6,2 \
55 * respectively for a 48 Mhz \
56 * i2c clock \
57 */ \
58 .slsu = _slsu, \
59 /* Tx FIFO threshold */ \
60 .tft = _tft, \
61 /* Rx FIFO threshold */ \
62 .rft = _rft, \
63 /* std. mode operation */ \
64 .clk_freq = clk, \
65 .sm = _sm, \
66}
67/*
68 * The board uses TODO <3> i2c controllers, initialize all of
69 * them with slave data setup time of 250 ns,
70 * Tx & Rx FIFO threshold values as 1 and standard
71 * mode of operation
72 */
73
74U5500_I2C_CONTROLLER(2, 0xe, 1, 1, 400000, I2C_FREQ_MODE_FAST);
75
76static struct lm3530_platform_data u5500_als_platform_data = {
77 .mode = LM3530_BL_MODE_MANUAL,
78 .als_input_mode = LM3530_INPUT_ALS1,
79 .max_current = LM3530_FS_CURR_26mA,
80 .pwm_pol_hi = true,
81 .als_avrg_time = LM3530_ALS_AVRG_TIME_512ms,
82 .brt_ramp_law = 1, /* Linear */
83 .brt_ramp_fall = LM3530_RAMP_TIME_8s,
84 .brt_ramp_rise = LM3530_RAMP_TIME_8s,
85 .als1_resistor_sel = LM3530_ALS_IMPD_13_53kOhm,
86 .als2_resistor_sel = LM3530_ALS_IMPD_Z,
87 .als_vmin = 730, /* mV */
88 .als_vmax = 1020, /* mV */
89 .brt_val = 0x7F, /* Max brightness */
90};
91
Linus Walleijb09628e2011-07-25 17:13:18 -070092static struct i2c_board_info __initdata u5500_i2c2_devices[] = {
93 {
94 /* Backlight */
95 I2C_BOARD_INFO("lm3530-led", 0x36),
96 .platform_data = &u5500_als_platform_data,
97 },
98};
99
Lee Jones18403422012-02-06 11:22:21 -0800100static void __init u5500_i2c_init(struct device *parent)
Linus Walleijb09628e2011-07-25 17:13:18 -0700101{
Lee Jones18403422012-02-06 11:22:21 -0800102 db5500_add_i2c2(parent, &u5500_i2c2_data);
Linus Walleijb09628e2011-07-25 17:13:18 -0700103 i2c_register_board_info(2, ARRAY_AND_SIZE(u5500_i2c2_devices));
104}
Mattias Wallinb7ddac52011-09-22 08:22:27 +0200105
106static struct ab5500_platform_data ab5500_plf_data = {
107 .irq = {
108 .base = 0,
109 .count = 0,
110 },
111 .init_settings = NULL,
112 .init_settings_sz = 0,
113 .pm_power_off = false,
114};
115
116static struct platform_device ab5500_device = {
117 .name = "ab5500-core",
118 .id = 0,
119 .dev = {
120 .platform_data = &ab5500_plf_data,
121 },
122 .num_resources = 0,
123};
124
125static struct platform_device *u5500_platform_devices[] __initdata = {
126 &ab5500_device,
127};
128
Lee Jones18403422012-02-06 11:22:21 -0800129static void __init u5500_uart_init(struct device *parent)
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +0530130{
Lee Jones18403422012-02-06 11:22:21 -0800131 db5500_add_uart0(parent, NULL);
132 db5500_add_uart1(parent, NULL);
133 db5500_add_uart2(parent, NULL);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +0530134}
Rabin Vincent591d8dd2010-05-03 08:46:51 +0100135
136static void __init u5500_init_machine(void)
137{
Lee Jones18403422012-02-06 11:22:21 -0800138 struct device *parent = NULL;
Lee Jonesb024a0c2012-02-06 11:22:25 -0800139 int i;
Lee Jones18403422012-02-06 11:22:21 -0800140
141 parent = u5500_init_devices();
Linus Walleijb09628e2011-07-25 17:13:18 -0700142 nmk_config_pins(u5500_pins, ARRAY_SIZE(u5500_pins));
Lee Jones18403422012-02-06 11:22:21 -0800143
144 u5500_i2c_init(parent);
145 u5500_sdi_init(parent);
146 u5500_uart_init(parent);
Mattias Wallinb7ddac52011-09-22 08:22:27 +0200147
Lee Jonesb024a0c2012-02-06 11:22:25 -0800148 for (i = 0; i < ARRAY_SIZE(u5500_platform_devices); i++)
149 u5500_platform_devices[i]->dev.parent = parent;
150
Mattias Wallinb7ddac52011-09-22 08:22:27 +0200151 platform_add_devices(u5500_platform_devices,
152 ARRAY_SIZE(u5500_platform_devices));
Rabin Vincent591d8dd2010-05-03 08:46:51 +0100153}
154
Per Forlinbab263e2010-12-05 12:49:03 +0100155MACHINE_START(U5500, "ST-Ericsson U5500 Platform")
Nicolas Pitrebc77b1a2011-07-05 22:38:18 -0400156 .atag_offset = 0x100,
Rabin Vincent591d8dd2010-05-03 08:46:51 +0100157 .map_io = u5500_map_io,
158 .init_irq = ux500_init_irq,
159 .timer = &ux500_timer,
Marc Zyngierbbf5f382011-09-06 10:23:45 +0100160 .handle_irq = gic_handle_irq,
Rabin Vincent591d8dd2010-05-03 08:46:51 +0100161 .init_machine = u5500_init_machine,
162MACHINE_END