blob: 82025ba70c0301b11326ac9f6ce3b2da6bcbefa4 [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>
Mattias Wallinb7ddac52011-09-22 08:22:27 +020013#include <linux/mfd/ab5500/ab5500.h>
Rabin Vincent591d8dd2010-05-03 08:46:51 +010014
15#include <asm/mach/arch.h>
16#include <asm/mach-types.h>
17
Linus Walleijb09628e2011-07-25 17:13:18 -070018#include <plat/pincfg.h>
19#include <plat/i2c.h>
Linus Walleij0f332862011-08-22 08:33:30 +010020#include <plat/gpio-nomadik.h>
Linus Walleijb09628e2011-07-25 17:13:18 -070021
Rabin Vincent591d8dd2010-05-03 08:46:51 +010022#include <mach/hardware.h>
23#include <mach/devices.h>
24#include <mach/setup.h>
25
Linus Walleijb09628e2011-07-25 17:13:18 -070026#include "pins-db5500.h"
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053027#include "devices-db5500.h"
Linus Walleijb09628e2011-07-25 17:13:18 -070028#include <linux/led-lm3530.h>
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +053029
Linus Walleijb09628e2011-07-25 17:13:18 -070030/*
31 * GPIO
32 */
33
34static pin_cfg_t u5500_pins[] = {
35 /* I2C */
36 GPIO218_I2C2_SCL | PIN_INPUT_PULLUP,
37 GPIO219_I2C2_SDA | PIN_INPUT_PULLUP,
38
39 /* DISPLAY_ENABLE */
40 GPIO226_GPIO | PIN_OUTPUT_LOW,
41
42 /* Backlight Enbale */
43 GPIO224_GPIO | PIN_OUTPUT_HIGH,
44};
45/*
46 * I2C
47 */
48
49#define U5500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
50static struct nmk_i2c_controller u5500_i2c##id##_data = { \
51 /* \
52 * slave data setup time, which is \
53 * 250 ns,100ns,10ns which is 14,6,2 \
54 * respectively for a 48 Mhz \
55 * i2c clock \
56 */ \
57 .slsu = _slsu, \
58 /* Tx FIFO threshold */ \
59 .tft = _tft, \
60 /* Rx FIFO threshold */ \
61 .rft = _rft, \
62 /* std. mode operation */ \
63 .clk_freq = clk, \
64 .sm = _sm, \
65}
66/*
67 * The board uses TODO <3> i2c controllers, initialize all of
68 * them with slave data setup time of 250 ns,
69 * Tx & Rx FIFO threshold values as 1 and standard
70 * mode of operation
71 */
72
73U5500_I2C_CONTROLLER(2, 0xe, 1, 1, 400000, I2C_FREQ_MODE_FAST);
74
75static struct lm3530_platform_data u5500_als_platform_data = {
76 .mode = LM3530_BL_MODE_MANUAL,
77 .als_input_mode = LM3530_INPUT_ALS1,
78 .max_current = LM3530_FS_CURR_26mA,
79 .pwm_pol_hi = true,
80 .als_avrg_time = LM3530_ALS_AVRG_TIME_512ms,
81 .brt_ramp_law = 1, /* Linear */
82 .brt_ramp_fall = LM3530_RAMP_TIME_8s,
83 .brt_ramp_rise = LM3530_RAMP_TIME_8s,
84 .als1_resistor_sel = LM3530_ALS_IMPD_13_53kOhm,
85 .als2_resistor_sel = LM3530_ALS_IMPD_Z,
86 .als_vmin = 730, /* mV */
87 .als_vmax = 1020, /* mV */
88 .brt_val = 0x7F, /* Max brightness */
89};
90
Linus Walleijb09628e2011-07-25 17:13:18 -070091static struct i2c_board_info __initdata u5500_i2c2_devices[] = {
92 {
93 /* Backlight */
94 I2C_BOARD_INFO("lm3530-led", 0x36),
95 .platform_data = &u5500_als_platform_data,
96 },
97};
98
99static void __init u5500_i2c_init(void)
100{
101 db5500_add_i2c2(&u5500_i2c2_data);
102 i2c_register_board_info(2, ARRAY_AND_SIZE(u5500_i2c2_devices));
103}
Mattias Wallinb7ddac52011-09-22 08:22:27 +0200104
105static struct ab5500_platform_data ab5500_plf_data = {
106 .irq = {
107 .base = 0,
108 .count = 0,
109 },
110 .init_settings = NULL,
111 .init_settings_sz = 0,
112 .pm_power_off = false,
113};
114
115static struct platform_device ab5500_device = {
116 .name = "ab5500-core",
117 .id = 0,
118 .dev = {
119 .platform_data = &ab5500_plf_data,
120 },
121 .num_resources = 0,
122};
123
124static struct platform_device *u5500_platform_devices[] __initdata = {
125 &ab5500_device,
126};
127
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +0530128static void __init u5500_uart_init(void)
129{
Linus Walleij5d7b8462010-10-14 13:57:59 +0200130 db5500_add_uart0(NULL);
131 db5500_add_uart1(NULL);
132 db5500_add_uart2(NULL);
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +0530133}
Rabin Vincent591d8dd2010-05-03 08:46:51 +0100134
135static void __init u5500_init_machine(void)
136{
137 u5500_init_devices();
Linus Walleijb09628e2011-07-25 17:13:18 -0700138 nmk_config_pins(u5500_pins, ARRAY_SIZE(u5500_pins));
139 u5500_i2c_init();
Per Forlinbab263e2010-12-05 12:49:03 +0100140 u5500_sdi_init();
Rabin Vincentfbf1eadf2010-09-29 19:46:32 +0530141 u5500_uart_init();
Mattias Wallinb7ddac52011-09-22 08:22:27 +0200142
143 platform_add_devices(u5500_platform_devices,
144 ARRAY_SIZE(u5500_platform_devices));
Rabin Vincent591d8dd2010-05-03 08:46:51 +0100145}
146
Per Forlinbab263e2010-12-05 12:49:03 +0100147MACHINE_START(U5500, "ST-Ericsson U5500 Platform")
Nicolas Pitrebc77b1a2011-07-05 22:38:18 -0400148 .atag_offset = 0x100,
Rabin Vincent591d8dd2010-05-03 08:46:51 +0100149 .map_io = u5500_map_io,
150 .init_irq = ux500_init_irq,
151 .timer = &ux500_timer,
152 .init_machine = u5500_init_machine,
153MACHINE_END