blob: f22419ed74a82cf394c69d0e5d51d2e53fad447d [file] [log] [blame]
viresh kumarbc4e8142010-04-01 12:30:58 +01001/*
2 * arch/arm/mach-spear3xx/spear3xx.c
3 *
4 * SPEAr3XX machines common source file
5 *
Viresh Kumarc5fa4fd2012-03-23 00:17:43 +05306 * Copyright (C) 2009-2012 ST Microelectronics
7 * Viresh Kumar <viresh.kumar@st.com>
viresh kumarbc4e8142010-04-01 12:30:58 +01008 *
9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied.
12 */
13
Viresh Kumar5fb00f92012-03-26 10:39:43 +053014#define pr_fmt(fmt) "SPEAr3xx: " fmt
15
Viresh Kumarc5fa4fd2012-03-23 00:17:43 +053016#include <linux/amba/pl022.h>
17#include <linux/amba/pl08x.h>
18#include <linux/of_irq.h>
viresh kumarbc4e8142010-04-01 12:30:58 +010019#include <linux/io.h>
Viresh Kumar0b7ee712012-03-26 10:29:23 +053020#include <asm/hardware/pl080.h>
viresh kumarbc4e8142010-04-01 12:30:58 +010021#include <asm/hardware/vic.h>
Viresh Kumar0b7ee712012-03-26 10:29:23 +053022#include <plat/pl080.h>
viresh kumarbc4e8142010-04-01 12:30:58 +010023#include <mach/generic.h>
Arnd Bergmann5019f0b2012-04-11 17:30:11 +000024#include <mach/spear.h>
viresh kumarbc4e8142010-04-01 12:30:58 +010025
Viresh Kumarc5fa4fd2012-03-23 00:17:43 +053026/* ssp device registration */
27struct pl022_ssp_controller pl022_plat_data = {
28 .bus_id = 0,
29 .enable_dma = 1,
30 .dma_filter = pl08x_filter_id,
31 .dma_tx_param = "ssp0_tx",
32 .dma_rx_param = "ssp0_rx",
33 /*
34 * This is number of spi devices that can be connected to spi. There are
35 * two type of chipselects on which slave devices can work. One is chip
36 * select provided by spi masters other is controlled through external
37 * gpio's. We can't use chipselect provided from spi master (because as
38 * soon as FIFO becomes empty, CS is disabled and transfer ends). So
39 * this number now depends on number of gpios available for spi. each
40 * slave on each master requires a separate gpio pin.
41 */
42 .num_chipselect = 2,
viresh kumarbc4e8142010-04-01 12:30:58 +010043};
44
Viresh Kumar0b7ee712012-03-26 10:29:23 +053045/* dmac device registration */
46struct pl08x_platform_data pl080_plat_data = {
47 .memcpy_channel = {
48 .bus_id = "memcpy",
49 .cctl = (PL080_BSIZE_16 << PL080_CONTROL_SB_SIZE_SHIFT | \
50 PL080_BSIZE_16 << PL080_CONTROL_DB_SIZE_SHIFT | \
51 PL080_WIDTH_32BIT << PL080_CONTROL_SWIDTH_SHIFT | \
52 PL080_WIDTH_32BIT << PL080_CONTROL_DWIDTH_SHIFT | \
53 PL080_CONTROL_PROT_BUFF | PL080_CONTROL_PROT_CACHE | \
54 PL080_CONTROL_PROT_SYS),
55 },
56 .lli_buses = PL08X_AHB1,
57 .mem_buses = PL08X_AHB1,
58 .get_signal = pl080_get_signal,
59 .put_signal = pl080_put_signal,
60};
viresh kumarbc4e8142010-04-01 12:30:58 +010061
Viresh Kumarc5fa4fd2012-03-23 00:17:43 +053062/*
63 * Following will create 16MB static virtual/physical mappings
64 * PHYSICAL VIRTUAL
65 * 0xD0000000 0xFD000000
66 * 0xFC000000 0xFC000000
67 */
viresh kumarbc4e8142010-04-01 12:30:58 +010068struct map_desc spear3xx_io_desc[] __initdata = {
69 {
Viresh Kumarc5fa4fd2012-03-23 00:17:43 +053070 .virtual = VA_SPEAR3XX_ICM1_2_BASE,
71 .pfn = __phys_to_pfn(SPEAR3XX_ICM1_2_BASE),
72 .length = SZ_16M,
viresh kumarbc4e8142010-04-01 12:30:58 +010073 .type = MT_DEVICE
74 }, {
Viresh Kumarc5fa4fd2012-03-23 00:17:43 +053075 .virtual = VA_SPEAR3XX_ICM3_SMI_CTRL_BASE,
76 .pfn = __phys_to_pfn(SPEAR3XX_ICM3_SMI_CTRL_BASE),
77 .length = SZ_16M,
viresh kumarbc4e8142010-04-01 12:30:58 +010078 .type = MT_DEVICE
79 },
80};
81
82/* This will create static memory mapping for selected devices */
83void __init spear3xx_map_io(void)
84{
85 iotable_init(spear3xx_io_desc, ARRAY_SIZE(spear3xx_io_desc));
viresh kumarbc4e8142010-04-01 12:30:58 +010086}
viresh kumar70f4c0b2010-04-01 12:31:29 +010087
Shiraz Hashim5c881d92011-02-16 07:40:32 +010088static void __init spear3xx_timer_init(void)
89{
90 char pclk_name[] = "pll3_48m_clk";
91 struct clk *gpt_clk, *pclk;
92
Viresh Kumar5df33a62012-04-10 09:02:35 +053093 spear3xx_clk_init();
94
Shiraz Hashim5c881d92011-02-16 07:40:32 +010095 /* get the system timer clock */
96 gpt_clk = clk_get_sys("gpt0", NULL);
97 if (IS_ERR(gpt_clk)) {
98 pr_err("%s:couldn't get clk for gpt\n", __func__);
99 BUG();
100 }
101
102 /* get the suitable parent clock for timer*/
103 pclk = clk_get(NULL, pclk_name);
104 if (IS_ERR(pclk)) {
105 pr_err("%s:couldn't get %s as parent for gpt\n",
106 __func__, pclk_name);
107 BUG();
108 }
109
110 clk_set_parent(gpt_clk, pclk);
111 clk_put(gpt_clk);
112 clk_put(pclk);
113
Viresh Kumar30551c02012-04-21 13:15:37 +0530114 spear_setup_of_timer();
Shiraz Hashim5c881d92011-02-16 07:40:32 +0100115}
116
117struct sys_timer spear3xx_timer = {
118 .init = spear3xx_timer_init,
119};
Viresh Kumarc5fa4fd2012-03-23 00:17:43 +0530120
121static const struct of_device_id vic_of_match[] __initconst = {
122 { .compatible = "arm,pl190-vic", .data = vic_of_init, },
123 { /* Sentinel */ }
124};
125
126void __init spear3xx_dt_init_irq(void)
127{
128 of_irq_init(vic_of_match);
129}