fpga.c 908 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * SDK7786 FPGA Support.
  3. *
  4. * Copyright (C) 2010 Paul Mundt
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/init.h>
  11. #include <linux/io.h>
  12. #include <linux/bcd.h>
  13. #include <mach/fpga.h>
  14. #define FPGA_REGS_BASE 0x07fff800
  15. #define FPGA_REGS_SIZE 0x490
  16. void __iomem *sdk7786_fpga_base;
  17. void __init sdk7786_fpga_init(void)
  18. {
  19. u16 version, date;
  20. sdk7786_fpga_base = ioremap_nocache(FPGA_REGS_BASE, FPGA_REGS_SIZE);
  21. if (unlikely(!sdk7786_fpga_base)) {
  22. panic("FPGA remapping failed.\n");
  23. return;
  24. }
  25. version = fpga_read_reg(FPGAVR);
  26. date = fpga_read_reg(FPGADR);
  27. pr_info("\tFPGA version:\t%d.%d (built on %d/%d/%d)\n",
  28. bcd2bin(version >> 8) & 0xf, bcd2bin(version & 0xf),
  29. ((date >> 12) & 0xf) + 2000,
  30. (date >> 8) & 0xf, bcd2bin(date & 0xff));
  31. }