lacie_v2-common.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * arch/arm/mach-kirkwood/lacie_v2-common.c
  3. *
  4. * This file is licensed under the terms of the GNU General Public
  5. * License version 2. This program is licensed "as is" without any
  6. * warranty of any kind, whether express or implied.
  7. */
  8. #include <linux/kernel.h>
  9. #include <linux/init.h>
  10. #include <linux/mtd/physmap.h>
  11. #include <linux/spi/flash.h>
  12. #include <linux/spi/spi.h>
  13. #include <linux/i2c.h>
  14. #include <linux/i2c/at24.h>
  15. #include <linux/gpio.h>
  16. #include <asm/mach/time.h>
  17. #include <mach/kirkwood.h>
  18. #include <mach/irqs.h>
  19. #include <plat/time.h>
  20. #include "common.h"
  21. /*****************************************************************************
  22. * 512KB SPI Flash on Boot Device (MACRONIX MX25L4005)
  23. ****************************************************************************/
  24. static struct mtd_partition lacie_v2_flash_parts[] = {
  25. {
  26. .name = "u-boot",
  27. .size = MTDPART_SIZ_FULL,
  28. .offset = 0,
  29. .mask_flags = MTD_WRITEABLE, /* force read-only */
  30. },
  31. };
  32. static const struct flash_platform_data lacie_v2_flash = {
  33. .type = "mx25l4005a",
  34. .name = "spi_flash",
  35. .parts = lacie_v2_flash_parts,
  36. .nr_parts = ARRAY_SIZE(lacie_v2_flash_parts),
  37. };
  38. static struct spi_board_info __initdata lacie_v2_spi_slave_info[] = {
  39. {
  40. .modalias = "m25p80",
  41. .platform_data = &lacie_v2_flash,
  42. .irq = -1,
  43. .max_speed_hz = 20000000,
  44. .bus_num = 0,
  45. .chip_select = 0,
  46. },
  47. };
  48. void __init lacie_v2_register_flash(void)
  49. {
  50. spi_register_board_info(lacie_v2_spi_slave_info,
  51. ARRAY_SIZE(lacie_v2_spi_slave_info));
  52. kirkwood_spi_init();
  53. }
  54. /*****************************************************************************
  55. * I2C devices
  56. ****************************************************************************/
  57. static struct at24_platform_data at24c04 = {
  58. .byte_len = SZ_4K / 8,
  59. .page_size = 16,
  60. };
  61. /*
  62. * i2c addr | chip | description
  63. * 0x50 | HT24LC04 | eeprom (512B)
  64. */
  65. static struct i2c_board_info __initdata lacie_v2_i2c_info[] = {
  66. {
  67. I2C_BOARD_INFO("24c04", 0x50),
  68. .platform_data = &at24c04,
  69. }
  70. };
  71. void __init lacie_v2_register_i2c_devices(void)
  72. {
  73. kirkwood_i2c_init();
  74. i2c_register_board_info(0, lacie_v2_i2c_info,
  75. ARRAY_SIZE(lacie_v2_i2c_info));
  76. }
  77. /*****************************************************************************
  78. * Hard Disk power
  79. ****************************************************************************/
  80. static int __initdata lacie_v2_gpio_hdd_power[] = { 16, 17, 41, 42, 43 };
  81. void __init lacie_v2_hdd_power_init(int hdd_num)
  82. {
  83. int i;
  84. int err;
  85. /* Power up all hard disks. */
  86. for (i = 0; i < hdd_num; i++) {
  87. err = gpio_request(lacie_v2_gpio_hdd_power[i], NULL);
  88. if (err == 0) {
  89. err = gpio_direction_output(
  90. lacie_v2_gpio_hdd_power[i], 1);
  91. /* Free the HDD power GPIOs. This allow user-space to
  92. * configure them via the gpiolib sysfs interface. */
  93. gpio_free(lacie_v2_gpio_hdd_power[i]);
  94. }
  95. if (err)
  96. pr_err("Failed to power up HDD%d\n", i + 1);
  97. }
  98. }