ebu.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * This program is free software; you can redistribute it and/or modify it
  3. * under the terms of the GNU General Public License version 2 as published
  4. * by the Free Software Foundation.
  5. *
  6. * EBU - the external bus unit attaches PCI, NOR and NAND
  7. *
  8. * Copyright (C) 2010 John Crispin <blogic@openwrt.org>
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/module.h>
  12. #include <linux/version.h>
  13. #include <linux/ioport.h>
  14. #include <lantiq_soc.h>
  15. /* all access to the ebu must be locked */
  16. DEFINE_SPINLOCK(ebu_lock);
  17. EXPORT_SYMBOL_GPL(ebu_lock);
  18. static struct resource ltq_ebu_resource = {
  19. .name = "ebu",
  20. .start = LTQ_EBU_BASE_ADDR,
  21. .end = LTQ_EBU_BASE_ADDR + LTQ_EBU_SIZE - 1,
  22. .flags = IORESOURCE_MEM,
  23. };
  24. /* remapped base addr of the clock unit and external bus unit */
  25. void __iomem *ltq_ebu_membase;
  26. static int __init lantiq_ebu_init(void)
  27. {
  28. /* insert and request the memory region */
  29. if (insert_resource(&iomem_resource, &ltq_ebu_resource) < 0)
  30. panic("Failed to insert ebu memory\n");
  31. if (request_mem_region(ltq_ebu_resource.start,
  32. resource_size(&ltq_ebu_resource), "ebu") < 0)
  33. panic("Failed to request ebu memory\n");
  34. /* remap ebu register range */
  35. ltq_ebu_membase = ioremap_nocache(ltq_ebu_resource.start,
  36. resource_size(&ltq_ebu_resource));
  37. if (!ltq_ebu_membase)
  38. panic("Failed to remap ebu memory\n");
  39. /* make sure to unprotect the memory region where flash is located */
  40. ltq_ebu_w32(ltq_ebu_r32(LTQ_EBU_BUSCON0) & ~EBU_WRDIS, LTQ_EBU_BUSCON0);
  41. return 0;
  42. }
  43. postcore_initcall(lantiq_ebu_init);