lacie_v2-common.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. #include "lacie_v2-common.h"
  22. /*****************************************************************************
  23. * 512KB SPI Flash on Boot Device (MACRONIX MX25L4005)
  24. ****************************************************************************/
  25. static struct mtd_partition lacie_v2_flash_parts[] = {
  26. {
  27. .name = "u-boot",
  28. .size = MTDPART_SIZ_FULL,
  29. .offset = 0,
  30. .mask_flags = MTD_WRITEABLE, /* force read-only */
  31. },
  32. };
  33. static const struct flash_platform_data lacie_v2_flash = {
  34. .type = "mx25l4005a",
  35. .name = "spi_flash",
  36. .parts = lacie_v2_flash_parts,
  37. .nr_parts = ARRAY_SIZE(lacie_v2_flash_parts),
  38. };
  39. static struct spi_board_info __initdata lacie_v2_spi_slave_info[] = {
  40. {
  41. .modalias = "m25p80",
  42. .platform_data = &lacie_v2_flash,
  43. .irq = -1,
  44. .max_speed_hz = 20000000,
  45. .bus_num = 0,
  46. .chip_select = 0,
  47. },
  48. };
  49. void __init lacie_v2_register_flash(void)
  50. {
  51. spi_register_board_info(lacie_v2_spi_slave_info,
  52. ARRAY_SIZE(lacie_v2_spi_slave_info));
  53. kirkwood_spi_init();
  54. }
  55. /*****************************************************************************
  56. * I2C devices
  57. ****************************************************************************/
  58. static struct at24_platform_data at24c04 = {
  59. .byte_len = SZ_4K / 8,
  60. .page_size = 16,
  61. };
  62. /*
  63. * i2c addr | chip | description
  64. * 0x50 | HT24LC04 | eeprom (512B)
  65. */
  66. static struct i2c_board_info __initdata lacie_v2_i2c_info[] = {
  67. {
  68. I2C_BOARD_INFO("24c04", 0x50),
  69. .platform_data = &at24c04,
  70. }
  71. };
  72. void __init lacie_v2_register_i2c_devices(void)
  73. {
  74. kirkwood_i2c_init();
  75. i2c_register_board_info(0, lacie_v2_i2c_info,
  76. ARRAY_SIZE(lacie_v2_i2c_info));
  77. }
  78. /*****************************************************************************
  79. * Hard Disk power
  80. ****************************************************************************/
  81. static int __initdata lacie_v2_gpio_hdd_power[] = { 16, 17, 41, 42, 43 };
  82. void __init lacie_v2_hdd_power_init(int hdd_num)
  83. {
  84. int i;
  85. int err;
  86. /* Power up all hard disks. */
  87. for (i = 0; i < hdd_num; i++) {
  88. err = gpio_request(lacie_v2_gpio_hdd_power[i], NULL);
  89. if (err == 0) {
  90. err = gpio_direction_output(
  91. lacie_v2_gpio_hdd_power[i], 1);
  92. /* Free the HDD power GPIOs. This allow user-space to
  93. * configure them via the gpiolib sysfs interface. */
  94. gpio_free(lacie_v2_gpio_hdd_power[i]);
  95. }
  96. if (err)
  97. pr_err("Failed to power up HDD%d\n", i + 1);
  98. }
  99. }