| 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 | * Copyright (C) 2011 Thomas Langer <thomas.langer@lantiq.com> |
| 7 | * Copyright (C) 2011 John Crispin <blogic@openwrt.org> |
| 8 | */ |
| 9 | |
| 10 | #include <lantiq_soc.h> |
| 11 | |
| 12 | #include "devices.h" |
| 13 | |
| 14 | #include "../prom.h" |
| 15 | |
| 16 | #define SOC_FALCON "Falcon" |
| 17 | #define SOC_FALCON_D "Falcon-D" |
| 18 | #define SOC_FALCON_V "Falcon-V" |
| 19 | #define SOC_FALCON_M "Falcon-M" |
| 20 | |
| 21 | #define PART_SHIFT 12 |
| 22 | #define PART_MASK 0x0FFFF000 |
| 23 | #define REV_SHIFT 28 |
| 24 | #define REV_MASK 0xF0000000 |
| 25 | #define SREV_SHIFT 22 |
| 26 | #define SREV_MASK 0x03C00000 |
| 27 | #define TYPE_SHIFT 26 |
| 28 | #define TYPE_MASK 0x3C000000 |
| 29 | |
| 30 | /* this parameter allows us enable/disable asc1 via commandline */ |
| 31 | static int register_asc1; |
| 32 | static int __init |
| 33 | ltq_parse_asc1(char *p) |
| 34 | { |
| 35 | register_asc1 = 1; |
| 36 | return 0; |
| 37 | } |
| 38 | __setup("use_asc1", ltq_parse_asc1); |
| 39 | |
| 40 | void __init |
| 41 | ltq_soc_setup(void) |
| 42 | { |
| 43 | ltq_register_asc(0); |
| 44 | ltq_register_wdt(); |
| 45 | falcon_register_gpio(); |
| 46 | if (register_asc1) |
| 47 | ltq_register_asc(1); |
| 48 | } |
| 49 | |
| 50 | void __init |
| 51 | ltq_soc_detect(struct ltq_soc_info *i) |
| 52 | { |
| 53 | u32 type; |
| 54 | i->partnum = (ltq_r32(LTQ_FALCON_CHIPID) & PART_MASK) >> PART_SHIFT; |
| 55 | i->rev = (ltq_r32(LTQ_FALCON_CHIPID) & REV_MASK) >> REV_SHIFT; |
| 56 | i->srev = ((ltq_r32(LTQ_FALCON_CHIPCONF) & SREV_MASK) >> SREV_SHIFT); |
| 57 | sprintf(i->rev_type, "%c%d%d", (i->srev & 0x4) ? ('B') : ('A'), |
| 58 | i->rev & 0x7, (i->srev & 0x3) + 1); |
| 59 | |
| 60 | switch (i->partnum) { |
| 61 | case SOC_ID_FALCON: |
| 62 | type = (ltq_r32(LTQ_FALCON_CHIPTYPE) & TYPE_MASK) >> TYPE_SHIFT; |
| 63 | switch (type) { |
| 64 | case 0: |
| 65 | i->name = SOC_FALCON_D; |
| 66 | break; |
| 67 | case 1: |
| 68 | i->name = SOC_FALCON_V; |
| 69 | break; |
| 70 | case 2: |
| 71 | i->name = SOC_FALCON_M; |
| 72 | break; |
| 73 | default: |
| 74 | i->name = SOC_FALCON; |
| 75 | break; |
| 76 | } |
| 77 | i->type = SOC_TYPE_FALCON; |
| 78 | break; |
| 79 | |
| 80 | default: |
| 81 | unreachable(); |
| 82 | break; |
| 83 | } |
| 84 | } |
| 85 | |