mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-21 08:53:41 +00:00
davinci: Encapsulate SoC-specific data in a structure
Create a structure to encapsulate SoC-specific information. This will assist in generalizing code so it can be used by different SoCs that have similar hardware but with minor differences such as having a different base address. The idea is that the code for each SoC fills out a structure with the correct information. The board-specific code then calls the SoC init routine which in turn will call a common init routine that makes a copy of the structure, maps in I/O regions, etc. After initialization, code can get a pointer to the structure by calling davinci_get_soc_info(). Eventually, the common init routine will make a copy of all of the data pointed to by the structure so the original data can be made __init_data. That way the data for SoC's that aren't being used won't consume memory for the entire life of the kernel. The structure will be extended in subsequent patches but initially, it holds the map_desc structure for any I/O regions the SoC/board wants statically mapped. Signed-off-by: Mark A. Greer <mgreer@mvista.com> Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
This commit is contained in:
parent
ac7b75b5bb
commit
79c3c0b729
@ -5,7 +5,7 @@
|
||||
|
||||
# Common objects
|
||||
obj-y := time.o irq.o clock.o serial.o io.o id.o psc.o \
|
||||
gpio.o devices.o dma.o usb.o
|
||||
gpio.o devices.o dma.o usb.o common.o
|
||||
|
||||
obj-$(CONFIG_DAVINCI_MUX) += mux.o
|
||||
obj-$(CONFIG_CP_INTC) += cp_intc.o
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <mach/serial.h>
|
||||
#include <mach/nand.h>
|
||||
#include <mach/mmc.h>
|
||||
#include <mach/common.h>
|
||||
|
||||
#define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e10000
|
||||
#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
|
||||
@ -188,7 +189,6 @@ static struct davinci_uart_config uart_config __initdata = {
|
||||
|
||||
static void __init dm355_evm_map_io(void)
|
||||
{
|
||||
davinci_map_common_io();
|
||||
dm355_init();
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <mach/serial.h>
|
||||
#include <mach/nand.h>
|
||||
#include <mach/mmc.h>
|
||||
#include <mach/common.h>
|
||||
|
||||
#define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e10000
|
||||
#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
|
||||
@ -187,7 +188,6 @@ static struct davinci_uart_config uart_config __initdata = {
|
||||
|
||||
static void __init dm355_leopard_map_io(void)
|
||||
{
|
||||
davinci_map_common_io();
|
||||
dm355_init();
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include <mach/psc.h>
|
||||
#include <mach/nand.h>
|
||||
#include <mach/mmc.h>
|
||||
#include <mach/common.h>
|
||||
|
||||
#define DM644X_EVM_PHY_MASK (0x2)
|
||||
#define DM644X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
|
||||
@ -609,7 +610,6 @@ static struct davinci_uart_config uart_config __initdata = {
|
||||
static void __init
|
||||
davinci_evm_map_io(void)
|
||||
{
|
||||
davinci_map_common_io();
|
||||
dm644x_init();
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
#include <mach/i2c.h>
|
||||
#include <mach/mmc.h>
|
||||
#include <mach/emac.h>
|
||||
#include <mach/common.h>
|
||||
|
||||
#define DM646X_EVM_PHY_MASK (0x2)
|
||||
#define DM646X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
|
||||
@ -265,7 +266,6 @@ static void __init evm_init_i2c(void)
|
||||
|
||||
static void __init davinci_map_io(void)
|
||||
{
|
||||
davinci_map_common_io();
|
||||
dm646x_init();
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include <mach/serial.h>
|
||||
#include <mach/psc.h>
|
||||
#include <mach/mux.h>
|
||||
#include <mach/common.h>
|
||||
|
||||
#define SFFSDR_PHY_MASK (0x2)
|
||||
#define SFFSDR_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
|
||||
@ -152,7 +153,6 @@ static struct davinci_uart_config uart_config __initdata = {
|
||||
|
||||
static void __init davinci_sffsdr_map_io(void)
|
||||
{
|
||||
davinci_map_common_io();
|
||||
dm644x_init();
|
||||
}
|
||||
|
||||
|
55
arch/arm/mach-davinci/common.c
Normal file
55
arch/arm/mach-davinci/common.c
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Code commons to all DaVinci SoCs.
|
||||
*
|
||||
* Author: Mark A. Greer <mgreer@mvista.com>
|
||||
*
|
||||
* 2009 (c) MontaVista Software, Inc. This file is licensed under
|
||||
* the terms of the GNU General Public License version 2. This program
|
||||
* is licensed "as is" without any warranty of any kind, whether express
|
||||
* or implied.
|
||||
*/
|
||||
#include <linux/module.h>
|
||||
#include <linux/io.h>
|
||||
|
||||
#include <asm/tlb.h>
|
||||
#include <asm/mach/map.h>
|
||||
|
||||
#include <mach/common.h>
|
||||
|
||||
struct davinci_soc_info davinci_soc_info;
|
||||
EXPORT_SYMBOL(davinci_soc_info);
|
||||
|
||||
void __init davinci_common_init(struct davinci_soc_info *soc_info)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!soc_info) {
|
||||
ret = -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
memcpy(&davinci_soc_info, soc_info, sizeof(struct davinci_soc_info));
|
||||
|
||||
if (davinci_soc_info.io_desc && (davinci_soc_info.io_desc_num > 0))
|
||||
iotable_init(davinci_soc_info.io_desc,
|
||||
davinci_soc_info.io_desc_num);
|
||||
|
||||
/*
|
||||
* Normally devicemaps_init() would flush caches and tlb after
|
||||
* mdesc->map_io(), but we must also do it here because of the CPU
|
||||
* revision check below.
|
||||
*/
|
||||
local_flush_tlb_all();
|
||||
flush_cache_all();
|
||||
|
||||
/*
|
||||
* We want to check CPU revision early for cpu_is_xxxx() macros.
|
||||
* IO space mapping must be initialized before we can do that.
|
||||
*/
|
||||
davinci_check_revision();
|
||||
|
||||
return;
|
||||
|
||||
err:
|
||||
pr_err("davinci_common_init: SoC Initialization failed\n");
|
||||
}
|
@ -16,6 +16,8 @@
|
||||
|
||||
#include <linux/spi/spi.h>
|
||||
|
||||
#include <asm/mach/map.h>
|
||||
|
||||
#include <mach/dm355.h>
|
||||
#include <mach/clock.h>
|
||||
#include <mach/cputype.h>
|
||||
@ -23,6 +25,7 @@
|
||||
#include <mach/psc.h>
|
||||
#include <mach/mux.h>
|
||||
#include <mach/irqs.h>
|
||||
#include <mach/common.h>
|
||||
|
||||
#include "clock.h"
|
||||
#include "mux.h"
|
||||
@ -522,8 +525,23 @@ static struct platform_device dm355_edma_device = {
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
static struct map_desc dm355_io_desc[] = {
|
||||
{
|
||||
.virtual = IO_VIRT,
|
||||
.pfn = __phys_to_pfn(IO_PHYS),
|
||||
.length = IO_SIZE,
|
||||
.type = MT_DEVICE
|
||||
},
|
||||
};
|
||||
|
||||
static struct davinci_soc_info davinci_soc_info_dm355 = {
|
||||
.io_desc = dm355_io_desc,
|
||||
.io_desc_num = ARRAY_SIZE(dm355_io_desc),
|
||||
};
|
||||
|
||||
void __init dm355_init(void)
|
||||
{
|
||||
davinci_common_init(&davinci_soc_info_dm355);
|
||||
davinci_clk_init(dm355_clks);
|
||||
davinci_mux_register(dm355_pins, ARRAY_SIZE(dm355_pins));;
|
||||
}
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include <linux/clk.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
#include <asm/mach/map.h>
|
||||
|
||||
#include <mach/dm644x.h>
|
||||
#include <mach/clock.h>
|
||||
#include <mach/cputype.h>
|
||||
@ -20,6 +22,7 @@
|
||||
#include <mach/irqs.h>
|
||||
#include <mach/psc.h>
|
||||
#include <mach/mux.h>
|
||||
#include <mach/common.h>
|
||||
|
||||
#include "clock.h"
|
||||
#include "mux.h"
|
||||
@ -463,8 +466,23 @@ void dm644x_init_emac(struct emac_platform_data *unused) {}
|
||||
|
||||
#endif
|
||||
|
||||
static struct map_desc dm644x_io_desc[] = {
|
||||
{
|
||||
.virtual = IO_VIRT,
|
||||
.pfn = __phys_to_pfn(IO_PHYS),
|
||||
.length = IO_SIZE,
|
||||
.type = MT_DEVICE
|
||||
},
|
||||
};
|
||||
|
||||
static struct davinci_soc_info davinci_soc_info_dm644x = {
|
||||
.io_desc = dm644x_io_desc,
|
||||
.io_desc_num = ARRAY_SIZE(dm644x_io_desc),
|
||||
};
|
||||
|
||||
void __init dm644x_init(void)
|
||||
{
|
||||
davinci_common_init(&davinci_soc_info_dm644x);
|
||||
davinci_clk_init(dm644x_clks);
|
||||
davinci_mux_register(dm644x_pins, ARRAY_SIZE(dm644x_pins));
|
||||
}
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include <linux/clk.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
#include <asm/mach/map.h>
|
||||
|
||||
#include <mach/dm646x.h>
|
||||
#include <mach/clock.h>
|
||||
#include <mach/cputype.h>
|
||||
@ -20,6 +22,7 @@
|
||||
#include <mach/irqs.h>
|
||||
#include <mach/psc.h>
|
||||
#include <mach/mux.h>
|
||||
#include <mach/common.h>
|
||||
|
||||
#include "clock.h"
|
||||
#include "mux.h"
|
||||
@ -442,8 +445,23 @@ void dm646x_init_emac(struct emac_platform_data *unused) {}
|
||||
|
||||
#endif
|
||||
|
||||
static struct map_desc dm646x_io_desc[] = {
|
||||
{
|
||||
.virtual = IO_VIRT,
|
||||
.pfn = __phys_to_pfn(IO_PHYS),
|
||||
.length = IO_SIZE,
|
||||
.type = MT_DEVICE
|
||||
},
|
||||
};
|
||||
|
||||
static struct davinci_soc_info davinci_soc_info_dm646x = {
|
||||
.io_desc = dm646x_io_desc,
|
||||
.io_desc_num = ARRAY_SIZE(dm646x_io_desc),
|
||||
};
|
||||
|
||||
void __init dm646x_init(void)
|
||||
{
|
||||
davinci_common_init(&davinci_soc_info_dm646x);
|
||||
davinci_clk_init(dm646x_clks);
|
||||
davinci_mux_register(dm646x_pins, ARRAY_SIZE(dm646x_pins));
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ struct sys_timer;
|
||||
extern struct sys_timer davinci_timer;
|
||||
|
||||
extern void davinci_irq_init(void);
|
||||
extern void davinci_map_common_io(void);
|
||||
|
||||
/* parameters describe VBUS sourcing for host mode */
|
||||
extern void setup_usb(unsigned mA, unsigned potpgt_msec);
|
||||
@ -25,4 +24,15 @@ extern void setup_usb(unsigned mA, unsigned potpgt_msec);
|
||||
/* parameters describe VBUS sourcing for host mode */
|
||||
extern void setup_usb(unsigned mA, unsigned potpgt_msec);
|
||||
|
||||
/* SoC specific init support */
|
||||
struct davinci_soc_info {
|
||||
struct map_desc *io_desc;
|
||||
unsigned long io_desc_num;
|
||||
};
|
||||
|
||||
extern struct davinci_soc_info davinci_soc_info;
|
||||
|
||||
extern void davinci_common_init(struct davinci_soc_info *soc_info);
|
||||
extern void davinci_check_revision(void);
|
||||
|
||||
#endif /* __ARCH_ARM_MACH_DAVINCI_COMMON_H */
|
||||
|
@ -13,10 +13,9 @@
|
||||
|
||||
#include <mach/hardware.h>
|
||||
|
||||
void __init dm355_init(void);
|
||||
|
||||
struct spi_board_info;
|
||||
|
||||
void __init dm355_init(void);
|
||||
void dm355_init_spi0(unsigned chipselect_mask,
|
||||
struct spi_board_info *info, unsigned len);
|
||||
|
||||
|
@ -9,47 +9,9 @@
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/io.h>
|
||||
|
||||
#include <asm/tlb.h>
|
||||
#include <asm/memory.h>
|
||||
|
||||
#include <asm/mach/map.h>
|
||||
#include <mach/clock.h>
|
||||
|
||||
extern void davinci_check_revision(void);
|
||||
|
||||
/*
|
||||
* The machine specific code may provide the extra mapping besides the
|
||||
* default mapping provided here.
|
||||
*/
|
||||
static struct map_desc davinci_io_desc[] __initdata = {
|
||||
{
|
||||
.virtual = IO_VIRT,
|
||||
.pfn = __phys_to_pfn(IO_PHYS),
|
||||
.length = IO_SIZE,
|
||||
.type = MT_DEVICE
|
||||
},
|
||||
};
|
||||
|
||||
void __init davinci_map_common_io(void)
|
||||
{
|
||||
iotable_init(davinci_io_desc, ARRAY_SIZE(davinci_io_desc));
|
||||
|
||||
/* Normally devicemaps_init() would flush caches and tlb after
|
||||
* mdesc->map_io(), but we must also do it here because of the CPU
|
||||
* revision check below.
|
||||
*/
|
||||
local_flush_tlb_all();
|
||||
flush_cache_all();
|
||||
|
||||
/* We want to check CPU revision early for cpu_is_xxxx() macros.
|
||||
* IO space mapping must be initialized before we can do that.
|
||||
*/
|
||||
davinci_check_revision();
|
||||
}
|
||||
|
||||
#define BETWEEN(p, st, sz) ((p) >= (st) && (p) < ((st) + (sz)))
|
||||
#define XLATE(p, pst, vst) ((void __iomem *)((p) - (pst) + (vst)))
|
||||
|
Loading…
Reference in New Issue
Block a user