rdc321x-southbridge.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * RDC321x MFD southbridge driver
  3. *
  4. * Copyright (C) 2007-2010 Florian Fainelli <florian@openwrt.org>
  5. * Copyright (C) 2010 Bernhard Loos <bernhardloos@googlemail.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. *
  21. */
  22. #include <linux/module.h>
  23. #include <linux/kernel.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/pci.h>
  26. #include <linux/mfd/core.h>
  27. #include <linux/mfd/rdc321x.h>
  28. static struct rdc321x_wdt_pdata rdc321x_wdt_pdata;
  29. static struct resource rdc321x_wdt_resource[] = {
  30. {
  31. .name = "wdt-reg",
  32. .start = RDC321X_WDT_CTRL,
  33. .end = RDC321X_WDT_CTRL + 0x3,
  34. .flags = IORESOURCE_IO,
  35. }
  36. };
  37. static struct rdc321x_gpio_pdata rdc321x_gpio_pdata = {
  38. .max_gpios = RDC321X_NUM_GPIO,
  39. };
  40. static struct resource rdc321x_gpio_resources[] = {
  41. {
  42. .name = "gpio-reg1",
  43. .start = RDC321X_GPIO_CTRL_REG1,
  44. .end = RDC321X_GPIO_CTRL_REG1 + 0x7,
  45. .flags = IORESOURCE_IO,
  46. }, {
  47. .name = "gpio-reg2",
  48. .start = RDC321X_GPIO_CTRL_REG2,
  49. .end = RDC321X_GPIO_CTRL_REG2 + 0x7,
  50. .flags = IORESOURCE_IO,
  51. }
  52. };
  53. static const struct mfd_cell rdc321x_sb_cells[] = {
  54. {
  55. .name = "rdc321x-wdt",
  56. .resources = rdc321x_wdt_resource,
  57. .num_resources = ARRAY_SIZE(rdc321x_wdt_resource),
  58. .platform_data = &rdc321x_wdt_pdata,
  59. .pdata_size = sizeof(rdc321x_wdt_pdata),
  60. }, {
  61. .name = "rdc321x-gpio",
  62. .resources = rdc321x_gpio_resources,
  63. .num_resources = ARRAY_SIZE(rdc321x_gpio_resources),
  64. .platform_data = &rdc321x_gpio_pdata,
  65. .pdata_size = sizeof(rdc321x_gpio_pdata),
  66. },
  67. };
  68. static int rdc321x_sb_probe(struct pci_dev *pdev,
  69. const struct pci_device_id *ent)
  70. {
  71. int err;
  72. err = pci_enable_device(pdev);
  73. if (err) {
  74. dev_err(&pdev->dev, "failed to enable device\n");
  75. return err;
  76. }
  77. rdc321x_gpio_pdata.sb_pdev = pdev;
  78. rdc321x_wdt_pdata.sb_pdev = pdev;
  79. return devm_mfd_add_devices(&pdev->dev, -1,
  80. rdc321x_sb_cells,
  81. ARRAY_SIZE(rdc321x_sb_cells),
  82. NULL, 0, NULL);
  83. }
  84. static const struct pci_device_id rdc321x_sb_table[] = {
  85. { PCI_DEVICE(PCI_VENDOR_ID_RDC, PCI_DEVICE_ID_RDC_R6030) },
  86. {}
  87. };
  88. MODULE_DEVICE_TABLE(pci, rdc321x_sb_table);
  89. static struct pci_driver rdc321x_sb_driver = {
  90. .name = "RDC321x Southbridge",
  91. .id_table = rdc321x_sb_table,
  92. .probe = rdc321x_sb_probe,
  93. };
  94. module_pci_driver(rdc321x_sb_driver);
  95. MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
  96. MODULE_LICENSE("GPL");
  97. MODULE_DESCRIPTION("RDC R-321x MFD southbridge driver");