at32ap.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (C) 2006 Atmel Corporation
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #include <linux/clk.h>
  9. #include <linux/err.h>
  10. #include <linux/init.h>
  11. #include <linux/platform_device.h>
  12. #include <asm/io.h>
  13. #include <asm/arch/init.h>
  14. #include <asm/arch/sm.h>
  15. struct at32_sm system_manager;
  16. static int __init at32_sm_init(void)
  17. {
  18. struct resource *regs;
  19. struct at32_sm *sm = &system_manager;
  20. int ret = -ENXIO;
  21. regs = platform_get_resource(&at32_sm_device, IORESOURCE_MEM, 0);
  22. if (!regs)
  23. goto fail;
  24. spin_lock_init(&sm->lock);
  25. sm->pdev = &at32_sm_device;
  26. ret = -ENOMEM;
  27. sm->regs = ioremap(regs->start, regs->end - regs->start + 1);
  28. if (!sm->regs)
  29. goto fail;
  30. return 0;
  31. fail:
  32. printk(KERN_ERR "Failed to initialize System Manager: %d\n", ret);
  33. return ret;
  34. }
  35. void __init setup_platform(void)
  36. {
  37. at32_sm_init();
  38. at32_clock_init();
  39. at32_portmux_init();
  40. }
  41. static int __init pdc_probe(struct platform_device *pdev)
  42. {
  43. struct clk *pclk, *hclk;
  44. pclk = clk_get(&pdev->dev, "pclk");
  45. if (IS_ERR(pclk)) {
  46. dev_err(&pdev->dev, "no pclk defined\n");
  47. return PTR_ERR(pclk);
  48. }
  49. hclk = clk_get(&pdev->dev, "hclk");
  50. if (IS_ERR(hclk)) {
  51. dev_err(&pdev->dev, "no hclk defined\n");
  52. clk_put(pclk);
  53. return PTR_ERR(hclk);
  54. }
  55. clk_enable(pclk);
  56. clk_enable(hclk);
  57. dev_info(&pdev->dev, "Atmel Peripheral DMA Controller enabled\n");
  58. return 0;
  59. }
  60. static struct platform_driver pdc_driver = {
  61. .probe = pdc_probe,
  62. .driver = {
  63. .name = "pdc",
  64. },
  65. };
  66. static int __init pdc_init(void)
  67. {
  68. return platform_driver_register(&pdc_driver);
  69. }
  70. arch_initcall(pdc_init);