Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008-2009 ST-Ericsson |
| 3 | * |
| 4 | * Author: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2, as |
| 8 | * published by the Free Software Foundation. |
| 9 | * |
| 10 | */ |
| 11 | #include <linux/types.h> |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/device.h> |
| 14 | #include <linux/amba/bus.h> |
| 15 | #include <linux/irq.h> |
Rabin Vincent | 94bdc0e | 2010-03-03 04:54:37 +0100 | [diff] [blame] | 16 | #include <linux/gpio.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 17 | #include <linux/platform_device.h> |
Rabin Vincent | cc2c133 | 2010-03-01 05:03:31 +0100 | [diff] [blame] | 18 | #include <linux/io.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 19 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 20 | #include <asm/mach/map.h> |
| 21 | #include <mach/hardware.h> |
Rabin Vincent | cc2c133 | 2010-03-01 05:03:31 +0100 | [diff] [blame] | 22 | #include <mach/setup.h> |
Rabin Vincent | 5b1f7dd | 2010-05-03 08:25:52 +0100 | [diff] [blame] | 23 | #include <mach/devices.h> |
Rabin Vincent | 94bdc0e | 2010-03-03 04:54:37 +0100 | [diff] [blame] | 24 | |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 25 | #include "devices-db8500.h" |
| 26 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 27 | static struct platform_device *platform_devs[] __initdata = { |
Rabin Vincent | 94bdc0e | 2010-03-03 04:54:37 +0100 | [diff] [blame] | 28 | &u8500_gpio_devs[0], |
| 29 | &u8500_gpio_devs[1], |
| 30 | &u8500_gpio_devs[2], |
| 31 | &u8500_gpio_devs[3], |
| 32 | &u8500_gpio_devs[4], |
| 33 | &u8500_gpio_devs[5], |
| 34 | &u8500_gpio_devs[6], |
| 35 | &u8500_gpio_devs[7], |
| 36 | &u8500_gpio_devs[8], |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 37 | &u8500_dma40_device, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 38 | }; |
| 39 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 40 | /* minimum static i/o mapping required to boot U8500 platforms */ |
| 41 | static struct map_desc u8500_io_desc[] __initdata = { |
Rabin Vincent | 1df20af | 2010-03-01 05:07:47 +0100 | [diff] [blame] | 42 | __IO_DEV_DESC(U8500_PRCMU_BASE, SZ_4K), |
Rabin Vincent | c9c0957 | 2010-05-03 07:34:53 +0100 | [diff] [blame] | 43 | __IO_DEV_DESC(U8500_GPIO0_BASE, SZ_4K), |
Rabin Vincent | 94bdc0e | 2010-03-03 04:54:37 +0100 | [diff] [blame] | 44 | __IO_DEV_DESC(U8500_GPIO1_BASE, SZ_4K), |
| 45 | __IO_DEV_DESC(U8500_GPIO2_BASE, SZ_4K), |
| 46 | __IO_DEV_DESC(U8500_GPIO3_BASE, SZ_4K), |
Linus Walleij | f946738c | 2010-08-19 10:27:49 +0100 | [diff] [blame] | 47 | __MEM_DEV_DESC(U8500_BOOT_ROM_BASE, SZ_1M), |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 48 | }; |
| 49 | |
Mattias Wallin | fcbd458 | 2010-12-02 16:20:42 +0100 | [diff] [blame^] | 50 | static struct map_desc u8500_ed_io_desc[] __initdata = { |
Rabin Vincent | 75a36ee | 2010-03-01 05:05:56 +0100 | [diff] [blame] | 51 | __IO_DEV_DESC(U8500_MTU0_BASE_ED, SZ_4K), |
Rabin Vincent | 1df20af | 2010-03-01 05:07:47 +0100 | [diff] [blame] | 52 | __IO_DEV_DESC(U8500_CLKRST7_BASE_ED, SZ_8K), |
Rabin Vincent | 75a36ee | 2010-03-01 05:05:56 +0100 | [diff] [blame] | 53 | }; |
| 54 | |
Mattias Wallin | fcbd458 | 2010-12-02 16:20:42 +0100 | [diff] [blame^] | 55 | static struct map_desc u8500_v1_io_desc[] __initdata = { |
Rabin Vincent | c9c0957 | 2010-05-03 07:34:53 +0100 | [diff] [blame] | 56 | __IO_DEV_DESC(U8500_MTU0_BASE, SZ_4K), |
Mattias Wallin | fcbd458 | 2010-12-02 16:20:42 +0100 | [diff] [blame^] | 57 | __IO_DEV_DESC(U8500_PRCMU_TCDM_BASE_V1, SZ_4K), |
| 58 | }; |
| 59 | |
| 60 | static struct map_desc u8500_v2_io_desc[] __initdata = { |
| 61 | __IO_DEV_DESC(U8500_PRCMU_TCDM_BASE, SZ_4K), |
Rabin Vincent | 75a36ee | 2010-03-01 05:05:56 +0100 | [diff] [blame] | 62 | }; |
| 63 | |
Linus Walleij | f946738c | 2010-08-19 10:27:49 +0100 | [diff] [blame] | 64 | /* |
| 65 | * Functions to differentiate between later ASICs |
| 66 | * We look into the end of the ROM to locate the hardcoded ASIC ID. |
| 67 | * This is only needed to differentiate between minor revisions and |
| 68 | * process variants of an ASIC, the major revisions are encoded in |
| 69 | * the cpuid. |
| 70 | */ |
| 71 | #define U8500_ASIC_ID_LOC_ED_V1 (U8500_BOOT_ROM_BASE + 0x1FFF4) |
| 72 | #define U8500_ASIC_ID_LOC_V2 (U8500_BOOT_ROM_BASE + 0x1DBF4) |
| 73 | #define U8500_ASIC_REV_ED 0x01 |
| 74 | #define U8500_ASIC_REV_V10 0xA0 |
| 75 | #define U8500_ASIC_REV_V11 0xA1 |
| 76 | #define U8500_ASIC_REV_V20 0xB0 |
| 77 | |
| 78 | /** |
| 79 | * struct db8500_asic_id - fields of the ASIC ID |
| 80 | * @process: the manufacturing process, 0x40 is 40 nm |
| 81 | * 0x00 is "standard" |
| 82 | * @partnumber: hithereto 0x8500 for DB8500 |
| 83 | * @revision: version code in the series |
| 84 | * This field definion is not formally defined but makes |
| 85 | * sense. |
| 86 | */ |
| 87 | struct db8500_asic_id { |
| 88 | u8 process; |
| 89 | u16 partnumber; |
| 90 | u8 revision; |
| 91 | }; |
| 92 | |
| 93 | /* This isn't going to change at runtime */ |
| 94 | static struct db8500_asic_id db8500_id; |
| 95 | |
| 96 | static void __init get_db8500_asic_id(void) |
| 97 | { |
| 98 | u32 asicid; |
| 99 | |
| 100 | if (cpu_is_u8500v1() || cpu_is_u8500ed()) |
| 101 | asicid = readl(__io_address(U8500_ASIC_ID_LOC_ED_V1)); |
| 102 | else if (cpu_is_u8500v2()) |
| 103 | asicid = readl(__io_address(U8500_ASIC_ID_LOC_V2)); |
| 104 | else |
| 105 | BUG(); |
| 106 | |
| 107 | db8500_id.process = (asicid >> 24); |
| 108 | db8500_id.partnumber = (asicid >> 16) & 0xFFFFU; |
| 109 | db8500_id.revision = asicid & 0xFFU; |
| 110 | } |
| 111 | |
| 112 | bool cpu_is_u8500v10(void) |
| 113 | { |
| 114 | return (db8500_id.revision == U8500_ASIC_REV_V10); |
| 115 | } |
| 116 | |
| 117 | bool cpu_is_u8500v11(void) |
| 118 | { |
| 119 | return (db8500_id.revision == U8500_ASIC_REV_V11); |
| 120 | } |
| 121 | |
| 122 | bool cpu_is_u8500v20(void) |
| 123 | { |
| 124 | return (db8500_id.revision == U8500_ASIC_REV_V20); |
| 125 | } |
| 126 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 127 | void __init u8500_map_io(void) |
| 128 | { |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 129 | ux500_map_io(); |
| 130 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 131 | iotable_init(u8500_io_desc, ARRAY_SIZE(u8500_io_desc)); |
Rabin Vincent | 75a36ee | 2010-03-01 05:05:56 +0100 | [diff] [blame] | 132 | |
| 133 | if (cpu_is_u8500ed()) |
Mattias Wallin | fcbd458 | 2010-12-02 16:20:42 +0100 | [diff] [blame^] | 134 | iotable_init(u8500_ed_io_desc, ARRAY_SIZE(u8500_ed_io_desc)); |
| 135 | else if (cpu_is_u8500v1()) |
| 136 | iotable_init(u8500_v1_io_desc, ARRAY_SIZE(u8500_v1_io_desc)); |
| 137 | else if (cpu_is_u8500v2()) |
| 138 | iotable_init(u8500_v2_io_desc, ARRAY_SIZE(u8500_v2_io_desc)); |
Linus Walleij | f946738c | 2010-08-19 10:27:49 +0100 | [diff] [blame] | 139 | |
| 140 | /* Read out the ASIC ID as early as we can */ |
| 141 | get_db8500_asic_id(); |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 142 | } |
| 143 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 144 | /* |
| 145 | * This function is called from the board init |
| 146 | */ |
| 147 | void __init u8500_init_devices(void) |
| 148 | { |
Linus Walleij | f946738c | 2010-08-19 10:27:49 +0100 | [diff] [blame] | 149 | /* Display some ASIC boilerplate */ |
| 150 | pr_info("DB8500: process: %02x, revision ID: 0x%02x\n", |
| 151 | db8500_id.process, db8500_id.revision); |
| 152 | if (cpu_is_u8500ed()) |
| 153 | pr_info("DB8500: Early Drop (ED)\n"); |
| 154 | else if (cpu_is_u8500v10()) |
| 155 | pr_info("DB8500: version 1.0\n"); |
| 156 | else if (cpu_is_u8500v11()) |
| 157 | pr_info("DB8500: version 1.1\n"); |
| 158 | else if (cpu_is_u8500v20()) |
| 159 | pr_info("DB8500: version 2.0\n"); |
| 160 | else |
| 161 | pr_warning("ASIC: UNKNOWN SILICON VERSION!\n"); |
| 162 | |
Linus Walleij | 7b8ddb0 | 2010-05-27 15:21:26 -0700 | [diff] [blame] | 163 | if (cpu_is_u8500ed()) |
| 164 | dma40_u8500ed_fixup(); |
| 165 | |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 166 | db8500_add_rtc(); |
| 167 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 168 | platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs)); |
| 169 | |
| 170 | return ; |
| 171 | } |