board-nsa310.c 2.1 KB

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