board-nsa310.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * arch/arm/mach-kirkwood/nsa-310-setup.c
  3. *
  4. * ZyXEL NSA-310 Setup
  5. *
  6. * This file is licensed under the terms of the GNU General Public
  7. * License version 2. This program is licensed "as is" without any
  8. * warranty of any kind, whether express or implied.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/i2c.h>
  13. #include <linux/gpio.h>
  14. #include <asm/mach-types.h>
  15. #include <asm/mach/arch.h>
  16. #include <mach/kirkwood.h>
  17. #include "common.h"
  18. #include "mpp.h"
  19. #define NSA310_GPIO_USB_POWER_OFF 21
  20. #define NSA310_GPIO_POWER_OFF 48
  21. static unsigned int nsa310_mpp_config[] __initdata = {
  22. MPP12_GPIO, /* led esata green */
  23. MPP13_GPIO, /* led esata red */
  24. MPP15_GPIO, /* led usb green */
  25. MPP16_GPIO, /* led usb red */
  26. MPP21_GPIO, /* control usb power off */
  27. MPP28_GPIO, /* led sys green */
  28. MPP29_GPIO, /* led sys red */
  29. MPP36_GPIO, /* key reset */
  30. MPP37_GPIO, /* key copy */
  31. MPP39_GPIO, /* led copy green */
  32. MPP40_GPIO, /* led copy red */
  33. MPP41_GPIO, /* led hdd green */
  34. MPP42_GPIO, /* led hdd red */
  35. MPP44_GPIO, /* ?? */
  36. MPP46_GPIO, /* key power */
  37. MPP48_GPIO, /* control power off */
  38. 0
  39. };
  40. static struct i2c_board_info __initdata nsa310_i2c_info[] = {
  41. { I2C_BOARD_INFO("adt7476", 0x2e) },
  42. };
  43. static void nsa310_power_off(void)
  44. {
  45. gpio_set_value(NSA310_GPIO_POWER_OFF, 1);
  46. }
  47. static int __init nsa310_gpio_request(unsigned int gpio, unsigned long flags,
  48. const char *label)
  49. {
  50. int err;
  51. err = gpio_request_one(gpio, flags, label);
  52. if (err)
  53. pr_err("NSA-310: can't setup GPIO%u (%s), err=%d\n",
  54. gpio, label, err);
  55. return err;
  56. }
  57. static void __init nsa310_gpio_init(void)
  58. {
  59. int err;
  60. err = nsa310_gpio_request(NSA310_GPIO_POWER_OFF, GPIOF_OUT_INIT_LOW,
  61. "Power Off");
  62. if (!err)
  63. pm_power_off = nsa310_power_off;
  64. nsa310_gpio_request(NSA310_GPIO_USB_POWER_OFF, GPIOF_OUT_INIT_LOW,
  65. "USB Power Off");
  66. }
  67. void __init nsa310_init(void)
  68. {
  69. u32 dev, rev;
  70. kirkwood_mpp_conf(nsa310_mpp_config);
  71. nsa310_gpio_init();
  72. kirkwood_pcie_id(&dev, &rev);
  73. i2c_register_board_info(0, ARRAY_AND_SIZE(nsa310_i2c_info));
  74. }
  75. static int __init nsa310_pci_init(void)
  76. {
  77. if (of_machine_is_compatible("zyxel,nsa310"))
  78. kirkwood_pcie_init(KW_PCIE0);
  79. return 0;
  80. }
  81. subsys_initcall(nsa310_pci_init);