blob: 1b2b81c0f27cf119e97d49f425379272c7b145f8 [file] [log] [blame]
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +01001/*
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 Vincent94bdc0e2010-03-03 04:54:37 +010016#include <linux/gpio.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010017#include <linux/platform_device.h>
Rabin Vincentcc2c1332010-03-01 05:03:31 +010018#include <linux/io.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010019
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010020#include <asm/mach/map.h>
21#include <mach/hardware.h>
Rabin Vincentcc2c1332010-03-01 05:03:31 +010022#include <mach/setup.h>
Rabin Vincent5b1f7dd2010-05-03 08:25:52 +010023#include <mach/devices.h>
Rabin Vincent94bdc0e2010-03-03 04:54:37 +010024
Rabin Vincentfbf1ead2010-09-29 19:46:32 +053025#include "devices-db8500.h"
26
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010027static struct platform_device *platform_devs[] __initdata = {
Linus Walleij7b8ddb02010-05-27 15:21:26 -070028 &u8500_dma40_device,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010029};
30
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010031/* minimum static i/o mapping required to boot U8500 platforms */
32static struct map_desc u8500_io_desc[] __initdata = {
Rabin Vincent92389ca2010-12-08 11:07:57 +053033 __IO_DEV_DESC(U8500_UART0_BASE, SZ_4K),
34 __IO_DEV_DESC(U8500_UART2_BASE, SZ_4K),
35 __IO_DEV_DESC(U8500_GIC_CPU_BASE, SZ_4K),
36 __IO_DEV_DESC(U8500_GIC_DIST_BASE, SZ_4K),
37 __IO_DEV_DESC(U8500_L2CC_BASE, SZ_4K),
38 __IO_DEV_DESC(U8500_TWD_BASE, SZ_4K),
39 __IO_DEV_DESC(U8500_MTU0_BASE, SZ_4K),
40 __IO_DEV_DESC(U8500_SCU_BASE, SZ_4K),
41 __IO_DEV_DESC(U8500_BACKUPRAM0_BASE, SZ_8K),
42
43 __IO_DEV_DESC(U8500_CLKRST1_BASE, SZ_4K),
44 __IO_DEV_DESC(U8500_CLKRST2_BASE, SZ_4K),
45 __IO_DEV_DESC(U8500_CLKRST3_BASE, SZ_4K),
46 __IO_DEV_DESC(U8500_CLKRST5_BASE, SZ_4K),
47 __IO_DEV_DESC(U8500_CLKRST6_BASE, SZ_4K),
48
Rabin Vincent1df20af2010-03-01 05:07:47 +010049 __IO_DEV_DESC(U8500_PRCMU_BASE, SZ_4K),
Rabin Vincentc9c09572010-05-03 07:34:53 +010050 __IO_DEV_DESC(U8500_GPIO0_BASE, SZ_4K),
Rabin Vincent94bdc0e2010-03-03 04:54:37 +010051 __IO_DEV_DESC(U8500_GPIO1_BASE, SZ_4K),
52 __IO_DEV_DESC(U8500_GPIO2_BASE, SZ_4K),
53 __IO_DEV_DESC(U8500_GPIO3_BASE, SZ_4K),
Linus Walleijf946738c2010-08-19 10:27:49 +010054 __MEM_DEV_DESC(U8500_BOOT_ROM_BASE, SZ_1M),
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010055};
56
Mattias Wallinfcbd4582010-12-02 16:20:42 +010057static struct map_desc u8500_ed_io_desc[] __initdata = {
Rabin Vincent75a36ee2010-03-01 05:05:56 +010058 __IO_DEV_DESC(U8500_MTU0_BASE_ED, SZ_4K),
Rabin Vincent1df20af2010-03-01 05:07:47 +010059 __IO_DEV_DESC(U8500_CLKRST7_BASE_ED, SZ_8K),
Rabin Vincent75a36ee2010-03-01 05:05:56 +010060};
61
Mattias Wallinfcbd4582010-12-02 16:20:42 +010062static struct map_desc u8500_v1_io_desc[] __initdata = {
Rabin Vincentc9c09572010-05-03 07:34:53 +010063 __IO_DEV_DESC(U8500_MTU0_BASE, SZ_4K),
Mattias Wallinfcbd4582010-12-02 16:20:42 +010064 __IO_DEV_DESC(U8500_PRCMU_TCDM_BASE_V1, SZ_4K),
65};
66
67static struct map_desc u8500_v2_io_desc[] __initdata = {
68 __IO_DEV_DESC(U8500_PRCMU_TCDM_BASE, SZ_4K),
Rabin Vincent75a36ee2010-03-01 05:05:56 +010069};
70
Linus Walleijf946738c2010-08-19 10:27:49 +010071/*
72 * Functions to differentiate between later ASICs
73 * We look into the end of the ROM to locate the hardcoded ASIC ID.
74 * This is only needed to differentiate between minor revisions and
75 * process variants of an ASIC, the major revisions are encoded in
76 * the cpuid.
77 */
78#define U8500_ASIC_ID_LOC_ED_V1 (U8500_BOOT_ROM_BASE + 0x1FFF4)
79#define U8500_ASIC_ID_LOC_V2 (U8500_BOOT_ROM_BASE + 0x1DBF4)
80#define U8500_ASIC_REV_ED 0x01
81#define U8500_ASIC_REV_V10 0xA0
82#define U8500_ASIC_REV_V11 0xA1
83#define U8500_ASIC_REV_V20 0xB0
84
85/**
86 * struct db8500_asic_id - fields of the ASIC ID
87 * @process: the manufacturing process, 0x40 is 40 nm
88 * 0x00 is "standard"
89 * @partnumber: hithereto 0x8500 for DB8500
90 * @revision: version code in the series
91 * This field definion is not formally defined but makes
92 * sense.
93 */
94struct db8500_asic_id {
95 u8 process;
96 u16 partnumber;
97 u8 revision;
98};
99
100/* This isn't going to change at runtime */
101static struct db8500_asic_id db8500_id;
102
103static void __init get_db8500_asic_id(void)
104{
105 u32 asicid;
106
107 if (cpu_is_u8500v1() || cpu_is_u8500ed())
108 asicid = readl(__io_address(U8500_ASIC_ID_LOC_ED_V1));
109 else if (cpu_is_u8500v2())
110 asicid = readl(__io_address(U8500_ASIC_ID_LOC_V2));
111 else
112 BUG();
113
114 db8500_id.process = (asicid >> 24);
115 db8500_id.partnumber = (asicid >> 16) & 0xFFFFU;
116 db8500_id.revision = asicid & 0xFFU;
117}
118
119bool cpu_is_u8500v10(void)
120{
121 return (db8500_id.revision == U8500_ASIC_REV_V10);
122}
123
124bool cpu_is_u8500v11(void)
125{
126 return (db8500_id.revision == U8500_ASIC_REV_V11);
127}
128
129bool cpu_is_u8500v20(void)
130{
131 return (db8500_id.revision == U8500_ASIC_REV_V20);
132}
133
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100134void __init u8500_map_io(void)
135{
136 iotable_init(u8500_io_desc, ARRAY_SIZE(u8500_io_desc));
Rabin Vincent75a36ee2010-03-01 05:05:56 +0100137
138 if (cpu_is_u8500ed())
Mattias Wallinfcbd4582010-12-02 16:20:42 +0100139 iotable_init(u8500_ed_io_desc, ARRAY_SIZE(u8500_ed_io_desc));
140 else if (cpu_is_u8500v1())
141 iotable_init(u8500_v1_io_desc, ARRAY_SIZE(u8500_v1_io_desc));
142 else if (cpu_is_u8500v2())
143 iotable_init(u8500_v2_io_desc, ARRAY_SIZE(u8500_v2_io_desc));
Linus Walleijf946738c2010-08-19 10:27:49 +0100144
145 /* Read out the ASIC ID as early as we can */
146 get_db8500_asic_id();
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100147}
148
Rabin Vincent01afdd12010-12-08 11:07:55 +0530149static resource_size_t __initdata db8500_gpio_base[] = {
150 U8500_GPIOBANK0_BASE,
151 U8500_GPIOBANK1_BASE,
152 U8500_GPIOBANK2_BASE,
153 U8500_GPIOBANK3_BASE,
154 U8500_GPIOBANK4_BASE,
155 U8500_GPIOBANK5_BASE,
156 U8500_GPIOBANK6_BASE,
157 U8500_GPIOBANK7_BASE,
158 U8500_GPIOBANK8_BASE,
159};
160
161static void __init db8500_add_gpios(void)
162{
163 struct nmk_gpio_platform_data pdata = {
164 /* No custom data yet */
165 };
166
167 dbx500_add_gpios(ARRAY_AND_SIZE(db8500_gpio_base),
168 IRQ_DB8500_GPIO0, &pdata);
169}
170
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100171/*
172 * This function is called from the board init
173 */
174void __init u8500_init_devices(void)
175{
Linus Walleijf946738c2010-08-19 10:27:49 +0100176 /* Display some ASIC boilerplate */
177 pr_info("DB8500: process: %02x, revision ID: 0x%02x\n",
178 db8500_id.process, db8500_id.revision);
179 if (cpu_is_u8500ed())
180 pr_info("DB8500: Early Drop (ED)\n");
181 else if (cpu_is_u8500v10())
182 pr_info("DB8500: version 1.0\n");
183 else if (cpu_is_u8500v11())
184 pr_info("DB8500: version 1.1\n");
185 else if (cpu_is_u8500v20())
186 pr_info("DB8500: version 2.0\n");
187 else
188 pr_warning("ASIC: UNKNOWN SILICON VERSION!\n");
189
Linus Walleij7b8ddb02010-05-27 15:21:26 -0700190 if (cpu_is_u8500ed())
191 dma40_u8500ed_fixup();
192
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530193 db8500_add_rtc();
Rabin Vincent01afdd12010-12-08 11:07:55 +0530194 db8500_add_gpios();
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530195
Martin Persson7c1a70e2010-12-08 15:13:42 +0100196 platform_device_register_simple("cpufreq-u8500", -1, NULL, 0);
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100197 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
198
199 return ;
200}