board-u5500.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  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. #include <linux/init.h>
  8. #include <linux/platform_device.h>
  9. #include <linux/amba/bus.h>
  10. #include <linux/irq.h>
  11. #include <linux/i2c.h>
  12. #include <linux/mfd/abx500/ab5500.h>
  13. #include <asm/hardware/gic.h>
  14. #include <asm/mach/arch.h>
  15. #include <asm/mach-types.h>
  16. #include <plat/pincfg.h>
  17. #include <plat/i2c.h>
  18. #include <plat/gpio-nomadik.h>
  19. #include <mach/hardware.h>
  20. #include <mach/devices.h>
  21. #include <mach/setup.h>
  22. #include "pins-db5500.h"
  23. #include "devices-db5500.h"
  24. #include <linux/led-lm3530.h>
  25. /*
  26. * GPIO
  27. */
  28. static pin_cfg_t u5500_pins[] = {
  29. /* I2C */
  30. GPIO218_I2C2_SCL | PIN_INPUT_PULLUP,
  31. GPIO219_I2C2_SDA | PIN_INPUT_PULLUP,
  32. /* DISPLAY_ENABLE */
  33. GPIO226_GPIO | PIN_OUTPUT_LOW,
  34. /* Backlight Enbale */
  35. GPIO224_GPIO | PIN_OUTPUT_HIGH,
  36. };
  37. /*
  38. * I2C
  39. */
  40. #define U5500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
  41. static struct nmk_i2c_controller u5500_i2c##id##_data = { \
  42. /* \
  43. * slave data setup time, which is \
  44. * 250 ns,100ns,10ns which is 14,6,2 \
  45. * respectively for a 48 Mhz \
  46. * i2c clock \
  47. */ \
  48. .slsu = _slsu, \
  49. /* Tx FIFO threshold */ \
  50. .tft = _tft, \
  51. /* Rx FIFO threshold */ \
  52. .rft = _rft, \
  53. /* std. mode operation */ \
  54. .clk_freq = clk, \
  55. .sm = _sm, \
  56. }
  57. /*
  58. * The board uses TODO <3> i2c controllers, initialize all of
  59. * them with slave data setup time of 250 ns,
  60. * Tx & Rx FIFO threshold values as 1 and standard
  61. * mode of operation
  62. */
  63. U5500_I2C_CONTROLLER(2, 0xe, 1, 1, 400000, I2C_FREQ_MODE_FAST);
  64. static struct lm3530_platform_data u5500_als_platform_data = {
  65. .mode = LM3530_BL_MODE_MANUAL,
  66. .als_input_mode = LM3530_INPUT_ALS1,
  67. .max_current = LM3530_FS_CURR_26mA,
  68. .pwm_pol_hi = true,
  69. .als_avrg_time = LM3530_ALS_AVRG_TIME_512ms,
  70. .brt_ramp_law = 1, /* Linear */
  71. .brt_ramp_fall = LM3530_RAMP_TIME_8s,
  72. .brt_ramp_rise = LM3530_RAMP_TIME_8s,
  73. .als1_resistor_sel = LM3530_ALS_IMPD_13_53kOhm,
  74. .als2_resistor_sel = LM3530_ALS_IMPD_Z,
  75. .als_vmin = 730, /* mV */
  76. .als_vmax = 1020, /* mV */
  77. .brt_val = 0x7F, /* Max brightness */
  78. };
  79. static struct i2c_board_info __initdata u5500_i2c2_devices[] = {
  80. {
  81. /* Backlight */
  82. I2C_BOARD_INFO("lm3530-led", 0x36),
  83. .platform_data = &u5500_als_platform_data,
  84. },
  85. };
  86. static void __init u5500_i2c_init(struct device *parent)
  87. {
  88. db5500_add_i2c2(parent, &u5500_i2c2_data);
  89. i2c_register_board_info(2, ARRAY_AND_SIZE(u5500_i2c2_devices));
  90. }
  91. static struct ab5500_platform_data ab5500_plf_data = {
  92. .irq = {
  93. .base = 0,
  94. .count = 0,
  95. },
  96. .init_settings = NULL,
  97. .init_settings_sz = 0,
  98. .pm_power_off = false,
  99. };
  100. static struct platform_device ab5500_device = {
  101. .name = "ab5500-core",
  102. .id = 0,
  103. .dev = {
  104. .platform_data = &ab5500_plf_data,
  105. },
  106. .num_resources = 0,
  107. };
  108. static struct platform_device *u5500_platform_devices[] __initdata = {
  109. &ab5500_device,
  110. };
  111. static void __init u5500_uart_init(struct device *parent)
  112. {
  113. db5500_add_uart0(parent, NULL);
  114. db5500_add_uart1(parent, NULL);
  115. db5500_add_uart2(parent, NULL);
  116. }
  117. static void __init u5500_init_machine(void)
  118. {
  119. struct device *parent = NULL;
  120. int i;
  121. parent = u5500_init_devices();
  122. nmk_config_pins(u5500_pins, ARRAY_SIZE(u5500_pins));
  123. u5500_i2c_init(parent);
  124. u5500_sdi_init(parent);
  125. u5500_uart_init(parent);
  126. for (i = 0; i < ARRAY_SIZE(u5500_platform_devices); i++)
  127. u5500_platform_devices[i]->dev.parent = parent;
  128. platform_add_devices(u5500_platform_devices,
  129. ARRAY_SIZE(u5500_platform_devices));
  130. }
  131. MACHINE_START(U5500, "ST-Ericsson U5500 Platform")
  132. .atag_offset = 0x100,
  133. .map_io = u5500_map_io,
  134. .init_irq = ux500_init_irq,
  135. .timer = &ux500_timer,
  136. .handle_irq = gic_handle_irq,
  137. .init_machine = u5500_init_machine,
  138. MACHINE_END