Last active
December 26, 2015 21:19
-
-
Save Embedded-linux/7215548 to your computer and use it in GitHub Desktop.
Template file for am335xevm "arch/arm/mach-omap2/board_am335x_evm.c"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| File Name: arch/arm/mach-omap2/board_am335x_evm.c | |
| Complete analysis of template board file, this file gives minium requirements | |
| for the board to up and it gives priority to user to add other I/O devices such | |
| as LCD, MMC, NAND for providing kerenl support. | |
| MACHINE_START(AM335XEVM, "am335xevm") | |
| /* Maintainer: Texas Instruments */ | |
| .atag_offset = 0x100, | |
| .map_io = am335x_evm_map_io, | |
| .init_early = am33xx_init_early, | |
| .init_irq = ti81xx_init_irq, | |
| .handle_irq = omap3_intc_handle_irq, | |
| .timer = &omap3_am33xx_timer, | |
| .init_machine = am335x_evm_init, | |
| MACHINE_END | |
| Board Machine Nmae identification "(AM335XEVM, "am335xevm")" | |
| atag_offset is to load boot load parameters into the kernel[to understand the kernel boot parameters], | |
| mapping io devices of am335x board to physical board, | |
| init_early is init the process form kernel side [correct me if I am wrong] | |
| intialization of Irq subsystem for board | |
| Handling irq routine | |
| Timer intialazation | |
| init_machine initializes all the board peripherals/IO devices | |
| " .map_io = am335x_evm_map_io," | |
| static void __init am335x_evm_map_io(void) | |
| { | |
| omap2_set_globals_am33xx(); | |
| omapam33xx_map_common_io(); | |
| } | |
| " .init_machine = am335x_evm_init," | |
| /* Called as part of board initialization, defined in MACHINE_START */ | |
| static void __init am335x_evm_init(void) | |
| { | |
| am33xx_cpuidle_init(); | |
| am33xx_mux_init(NULL); | |
| omap_serial_init(); | |
| am335x_rtc_init(); | |
| clkout2_enable(); | |
| omap_sdrc_init(NULL, NULL); | |
| } | |
| "/* RTC initialization function called in am335x_evm_init() */" | |
| static void am335x_rtc_init() | |
| { | |
| void __iomem *base; | |
| struct clk *clk; | |
| struct omap_hwmod *oh; | |
| struct platform_device *pdev; | |
| char *dev_name = "am33xx-rtc"; | |
| clk = clk_get(NULL, "rtc_fck"); | |
| if (IS_ERR(clk)) { | |
| pr_err("rtc : Failed to get RTC clock\n"); | |
| return; | |
| } | |
| if (clk_enable(clk)) { | |
| pr_err("rtc: Clock Enable Failed\n"); | |
| return; | |
| } | |
| base = ioremap(AM33XX_RTC_BASE, SZ_4K); | |
| if (WARN_ON(!base)) | |
| return; | |
| /* Unlock the rtc's registers */ | |
| writel(0x83e70b13, base + 0x6c); | |
| writel(0x95a4f1e0, base + 0x70); | |
| /* | |
| * Enable the 32K OSc | |
| * TODO: Need a better way to handle this | |
| * Since we want the clock to be running before mmc init | |
| * we need to do it before the rtc probe happens | |
| */ | |
| writel(0x48, base + 0x54); | |
| iounmap(base); | |
| am335x_rtc_info.pm_off = true; | |
| clk_disable(clk); | |
| clk_put(clk); | |
| oh = omap_hwmod_lookup("rtc"); | |
| if (!oh) { | |
| pr_err("could not look up %s\n", "rtc"); | |
| return; | |
| } | |
| pdev = omap_device_build(dev_name, -1, oh, &am335x_rtc_info, | |
| sizeof(struct omap_rtc_pdata), NULL, 0, 0); | |
| WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n", | |
| dev_name, oh->name); | |
| } | |
| "/* RTC initialization info structure */" | |
| static struct omap_rtc_pdata am335x_rtc_info = { | |
| .pm_off = false, | |
| .wakeup_capable = 0, | |
| }; | |
| /* cpu_idle_init() , function declared in am335x_evm_init() */ | |
| static void __init am33xx_cpuidle_init(void) | |
| { | |
| int ret; | |
| am33xx_cpuidle_pdata.emif_base = am33xx_get_mem_ctlr(); | |
| ret = platform_device_register(&am33xx_cpuidle_device); | |
| if (ret) | |
| pr_warning("AM33XX cpuidle registration failed\n"); | |
| } | |
| "/* initialization data required for cpu_idel_init() */ " | |
| /* AM33XX devices support DDR2 power down */ | |
| static struct am33xx_cpuidle_config am33xx_cpuidle_pdata = { | |
| .ddr2_pdown = 1, | |
| }; | |
| static struct resource am33xx_cpuidle_resources[] = { | |
| { | |
| .start = AM33XX_EMIF0_BASE, | |
| .end = AM33XX_EMIF0_BASE + SZ_32K - 1, | |
| .flags = IORESOURCE_MEM, | |
| }, | |
| }; | |
| static struct platform_device am33xx_cpuidle_device = { | |
| .name = "cpuidle-am33xx", | |
| .num_resources = ARRAY_SIZE(am33xx_cpuidle_resources), | |
| .resource = am33xx_cpuidle_resources, | |
| .dev = { | |
| .platform_data = &am33xx_cpuidle_pdata, | |
| }, | |
| }; | |
| "/* GPIO Base initialization data */" | |
| void __iomem *am33xx_gpio0_base; | |
| /* am33xx_get_gpio0_base is needed in arch/arm/mach-omap2/sleep33xx.S */ | |
| void __iomem *am33xx_get_gpio0_base(void) | |
| { | |
| am33xx_gpio0_base = ioremap(AM33XX_GPIO0_BASE, SZ_4K); | |
| return am33xx_gpio0_base; | |
| } | |
| "/* Emif info used for cpu_idle initilization */" | |
| void __iomem *am33xx_emif_base; | |
| void __iomem * __init am33xx_get_mem_ctlr(void) | |
| { | |
| am33xx_emif_base = ioremap(AM33XX_EMIF0_BASE, SZ_32K); | |
| if (!am33xx_emif_base) | |
| pr_warning("%s: Unable to map DDR2 controller", __func__); | |
| return am33xx_emif_base; | |
| } | |
| "/* Pin mux configuration used for all devices to muxing */" | |
| /* module pin mux structure */ | |
| struct pinmux_config { | |
| const char *string_name; /* signal name format */ | |
| int val; /* Options for the mux register value */ | |
| }; | |
| /* | |
| * @pin_mux - single module pin-mux structure which defines pin-mux | |
| * details for all its pins. | |
| */ | |
| static void setup_pin_mux(struct pinmux_config *pin_mux) | |
| { | |
| int i; | |
| for (i = 0; pin_mux->string_name != NULL; pin_mux++) | |
| omap_mux_init_signal(pin_mux->string_name, pin_mux->val); | |
| } | |
| "/* clkout enable including pin muxing */" | |
| /* Enable clkout2 */ | |
| static struct pinmux_config clkout2_pin_mux[] = { | |
| {"xdma_event_intr1.clkout2", OMAP_MUX_MODE3 | AM33XX_PIN_OUTPUT}, | |
| {NULL, 0}, | |
| }; | |
| static void __init clkout2_enable(void) | |
| { | |
| struct clk *ck_32; | |
| ck_32 = clk_get(NULL, "clkout2_ck"); | |
| if (IS_ERR(ck_32)) { | |
| pr_err("Cannot clk_get ck_32\n"); | |
| return; | |
| } | |
| clk_enable(ck_32); | |
| setup_pin_mux(clkout2_pin_mux); | |
| } | |
| "/* TO get the board id */" | |
| /* | |
| * am335x_evm_get_id - returns Board Type (EVM/BB/EVM-SK ...) | |
| * | |
| * Note: | |
| * returns BEAGLE_BONE_A3 as the board port example is built | |
| * around that board only. | |
| */ | |
| int am335x_evm_get_id(void) | |
| { | |
| return am33xx_evmid; | |
| } | |
| EXPORT_SYMBOL(am335x_evm_get_id); | |
| "/* Board port number */" | |
| //***************** EVM ID is necessary in some supporting SW for AM335x - | |
| //* To eliminate dependency, board port developers should search for | |
| // functions that call am335x_evm_get_id() | |
| // | |
| //* For Board Port the evm id is defaulted to Beagle Bone | |
| static int am33xx_evmid = BEAGLE_BONE_A3; | |
| /* Header Files */ | |
| /* Header for code common to all OMAP2+ machines. */ | |
| #include "common.h" | |
| "/* Board supported I/O device spefic files */ " | |
| #include "board-flash.h" /* Flash memory supported platform files */ | |
| #include "cpuidle33xx.h" | |
| #include "mux.h" | |
| #include "devices.h" | |
| #include "hsmmc.h" /*MMC supported */ | |
| "/* Platform supported files of mach-omap2 */" | |
| #include <plat/omap_device.h> | |
| #include <plat/irqs.h> | |
| #include <plat/board.h> | |
| #include <plat/common.h> | |
| #include <plat/lcdc.h> | |
| #include <plat/usb.h> | |
| #include <plat/mmc.h> | |
| #include <plat/emif.h> /* cpu_idle supported files */ | |
| "/* asm register definitions files */" | |
| #include <asm/mach-types.h> | |
| #include <asm/mach/arch.h> /* arch. definition supports to am335x_evm machine */ | |
| #include <asm/mach/map.h> /* am335x_evm machine mapping to io devices */ | |
| #include <asm/hardware/asp.h> | |
| "/* Machine spefic supported header files */" | |
| #include <mach/hardware.h> | |
| #include <mach/board-am335xevm.h> | |
| /* LCD controller supported header[no need to add in this file] */ | |
| /* LCD controller is similar to DA850 */ | |
| #include <video/da8xx-fb.h> | |
| /* kernel supported apis for linux system */ | |
| #include <linux/i2c.h> | |
| #include <linux/i2c/at24.h> | |
| #include <linux/phy.h> | |
| #include <linux/gpio.h> | |
| #include <linux/spi/spi.h> | |
| #include <linux/spi/flash.h> | |
| #include <linux/gpio_keys.h> | |
| #include <linux/input.h> | |
| #include <linux/input/matrix_keypad.h> | |
| #include <linux/mtd/mtd.h> | |
| #include <linux/mtd/nand.h> | |
| #include <linux/mtd/partitions.h> | |
| #include <linux/platform_device.h> | |
| #include <linux/clk.h> | |
| #include <linux/err.h> | |
| #include <linux/wl12xx.h> | |
| #include <linux/ethtool.h> | |
| #include <linux/mfd/tps65910.h> | |
| #include <linux/mfd/tps65217.h> | |
| #include <linux/pwm_backlight.h> | |
| #include <linux/rtc/rtc-omap.h> | |
| /* Header files supporting to insert this file as module in the linux sytem */ | |
| #include <linux/kernel.h> | |
| #include <linux/init.h> | |
| #include <linux/module.h> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment