xref: /openbmc/linux/arch/arm/mach-spear/spear3xx.c (revision 53f9cd5c)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * arch/arm/mach-spear3xx/spear3xx.c
4  *
5  * SPEAr3XX machines common source file
6  *
7  * Copyright (C) 2009-2012 ST Microelectronics
8  * Viresh Kumar <vireshk@kernel.org>
9  */
10 
11 #define pr_fmt(fmt) "SPEAr3xx: " fmt
12 
13 #include <linux/amba/pl022.h>
14 #include <linux/amba/pl080.h>
15 #include <linux/clk.h>
16 #include <linux/io.h>
17 #include <asm/mach/map.h>
18 #include "pl080.h"
19 #include "generic.h"
20 #include "spear.h"
21 #include "misc_regs.h"
22 
23 /* ssp device registration */
24 struct pl022_ssp_controller pl022_plat_data = {
25 	.bus_id = 0,
26 	.enable_dma = 1,
27 	.dma_filter = pl08x_filter_id,
28 	.dma_tx_param = "ssp0_tx",
29 	.dma_rx_param = "ssp0_rx",
30 };
31 
32 /* dmac device registration */
33 struct pl08x_platform_data pl080_plat_data = {
34 	.memcpy_burst_size = PL08X_BURST_SZ_16,
35 	.memcpy_bus_width = PL08X_BUS_WIDTH_32_BITS,
36 	.memcpy_prot_buff = true,
37 	.memcpy_prot_cache = true,
38 	.lli_buses = PL08X_AHB1,
39 	.mem_buses = PL08X_AHB1,
40 	.get_xfer_signal = pl080_get_signal,
41 	.put_xfer_signal = pl080_put_signal,
42 };
43 
44 /*
45  * Following will create 16MB static virtual/physical mappings
46  * PHYSICAL		VIRTUAL
47  * 0xD0000000		0xFD000000
48  * 0xFC000000		0xFC000000
49  */
50 struct map_desc spear3xx_io_desc[] __initdata = {
51 	{
52 		.virtual	= (unsigned long)VA_SPEAR_ICM1_2_BASE,
53 		.pfn		= __phys_to_pfn(SPEAR_ICM1_2_BASE),
54 		.length		= SZ_16M,
55 		.type		= MT_DEVICE
56 	}, {
57 		.virtual	= (unsigned long)VA_SPEAR_ICM3_SMI_CTRL_BASE,
58 		.pfn		= __phys_to_pfn(SPEAR_ICM3_SMI_CTRL_BASE),
59 		.length		= SZ_16M,
60 		.type		= MT_DEVICE
61 	},
62 };
63 
64 /* This will create static memory mapping for selected devices */
65 void __init spear3xx_map_io(void)
66 {
67 	iotable_init(spear3xx_io_desc, ARRAY_SIZE(spear3xx_io_desc));
68 }
69 
70 void __init spear3xx_timer_init(void)
71 {
72 	char pclk_name[] = "pll3_clk";
73 	struct clk *gpt_clk, *pclk;
74 
75 	spear3xx_clk_init(MISC_BASE, VA_SPEAR320_SOC_CONFIG_BASE);
76 
77 	/* get the system timer clock */
78 	gpt_clk = clk_get_sys("gpt0", NULL);
79 	if (IS_ERR(gpt_clk)) {
80 		pr_err("%s:couldn't get clk for gpt\n", __func__);
81 		BUG();
82 	}
83 
84 	/* get the suitable parent clock for timer*/
85 	pclk = clk_get(NULL, pclk_name);
86 	if (IS_ERR(pclk)) {
87 		pr_err("%s:couldn't get %s as parent for gpt\n",
88 				__func__, pclk_name);
89 		BUG();
90 	}
91 
92 	clk_set_parent(gpt_clk, pclk);
93 	clk_put(gpt_clk);
94 	clk_put(pclk);
95 
96 	spear_setup_of_timer();
97 }
98