board-nsa310.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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/gpio.h>
  13. #include <mach/kirkwood.h>
  14. #include <linux/of.h>
  15. #include "common.h"
  16. #include "mpp.h"
  17. #define NSA310_GPIO_USB_POWER_OFF 21
  18. #define NSA310_GPIO_POWER_OFF 48
  19. static unsigned int nsa310_mpp_config[] __initdata = {
  20. MPP12_GPIO, /* led esata green */
  21. MPP13_GPIO, /* led esata red */
  22. MPP15_GPIO, /* led usb green */
  23. MPP16_GPIO, /* led usb red */
  24. MPP21_GPIO, /* control usb power off */
  25. MPP28_GPIO, /* led sys green */
  26. MPP29_GPIO, /* led sys red */
  27. MPP36_GPIO, /* key reset */
  28. MPP37_GPIO, /* key copy */
  29. MPP39_GPIO, /* led copy green */
  30. MPP40_GPIO, /* led copy red */
  31. MPP41_GPIO, /* led hdd green */
  32. MPP42_GPIO, /* led hdd red */
  33. MPP44_GPIO, /* ?? */
  34. MPP46_GPIO, /* key power */
  35. MPP48_GPIO, /* control power off */
  36. 0
  37. };
  38. static struct i2c_board_info __initdata nsa310_i2c_info[] = {
  39. { I2C_BOARD_INFO("adt7476", 0x2e) },
  40. };
  41. static void nsa310_power_off(void)
  42. {
  43. gpio_set_value(NSA310_GPIO_POWER_OFF, 1);
  44. }
  45. static int __init nsa310_gpio_request(unsigned int gpio, unsigned long flags,
  46. const char *label)
  47. {
  48. int err;
  49. err = gpio_request_one(gpio, flags, label);
  50. if (err)
  51. pr_err("NSA-310: can't setup GPIO%u (%s), err=%d\n",
  52. gpio, label, err);
  53. return err;
  54. }
  55. static void __init nsa310_gpio_init(void)
  56. {
  57. int err;
  58. err = nsa310_gpio_request(NSA310_GPIO_POWER_OFF, GPIOF_OUT_INIT_LOW,
  59. "Power Off");
  60. if (!err)
  61. pm_power_off = nsa310_power_off;
  62. nsa310_gpio_request(NSA310_GPIO_USB_POWER_OFF, GPIOF_OUT_INIT_LOW,
  63. "USB Power Off");
  64. }
  65. void __init nsa310_init(void)
  66. {
  67. kirkwood_mpp_conf(nsa310_mpp_config);
  68. nsa310_gpio_init();
  69. i2c_register_board_info(0, ARRAY_AND_SIZE(nsa310_i2c_info));
  70. }
  71. static int __init nsa310_pci_init(void)
  72. {
  73. if (of_machine_is_compatible("zyxel,nsa310"))
  74. kirkwood_pcie_init(KW_PCIE0);
  75. return 0;
  76. }
  77. subsys_initcall(nsa310_pci_init);