Paul Mundt | efd590d | 2010-01-20 15:08:36 +0900 | [diff] [blame] | 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 | |
| 15 | #define FPGA_REGS_BASE 0x07fff800 |
| 16 | #define FPGA_REGS_SIZE 0x490 |
| 17 | |
| 18 | void __iomem *sdk7786_fpga_base; |
| 19 | |
| 20 | void __init sdk7786_fpga_init(void) |
| 21 | { |
| 22 | u16 version, date; |
| 23 | |
| 24 | sdk7786_fpga_base = ioremap_nocache(FPGA_REGS_BASE, FPGA_REGS_SIZE); |
| 25 | if (unlikely(!sdk7786_fpga_base)) { |
| 26 | panic("FPGA remapping failed.\n"); |
| 27 | return; |
| 28 | } |
| 29 | |
| 30 | version = fpga_read_reg(FPGAVR); |
| 31 | date = fpga_read_reg(FPGADR); |
| 32 | |
| 33 | pr_info("\tFPGA version:\t%d.%d (built on %d/%d/%d)\n", |
| 34 | bcd2bin(version >> 8) & 0xf, bcd2bin(version & 0xf), |
| 35 | ((date >> 12) & 0xf) + 2000, |
| 36 | (date >> 8) & 0xf, bcd2bin(date & 0xff)); |
| 37 | } |