/* * (C) Copyright 2004-2011 * Texas Instruments, * * Author : * Sunil Kumar * Shashi Ranjan * * Derived from Beagle Board and 3430 SDP code by * Richard Woodruff * Syed Mohammed Khasim * * * SPDX-License-Identifier: GPL-2.0+ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "h1.h" #include #ifdef CONFIG_USB_EHCI #include #include #endif #define TWL4030_I2C_BUS 0 DECLARE_GLOBAL_DATA_PTR; /* * Routine: board_init * Description: Early hardware init. */ int board_init(void) { gpmc_init(); /* in SRAM or SDRAM, finish GPMC */ /* board id for Linux */ gd->bd->bi_arch_number = MACH_TYPE_OMAP3_BEAGLE; /* boot param addr */ gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100); return 0; } #ifdef CONFIG_SPL_BUILD /* * Routine: get_board_mem_timings * Description: If we use SPL then there is no x-loader nor config header * so we have to setup the DDR timings ourself on both banks. */ void get_board_mem_timings(struct board_sdrc_timings *timings) { int pop_mfr, pop_id; /* * We need to identify what PoP memory is on the board so that * we know what timings to use. If we can't identify it then * we know it's an xM. To map the ID values please see nand_ids.c */ identify_nand_chip(&pop_mfr, &pop_id); timings->mr = MICRON_V_MR_165; if (pop_mfr == 0) { /* 256MB DDR */ timings->mcfg = MICRON_V_MCFG_200(256 << 20); timings->ctrla = MICRON_V_ACTIMA_200; timings->ctrlb = MICRON_V_ACTIMB_200; timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz; } else { /* Assume 128MB and Micron/165MHz timings to be safe */ timings->mcfg = MICRON_V_MCFG_165(128 << 20); timings->ctrla = MICRON_V_ACTIMA_165; timings->ctrlb = MICRON_V_ACTIMB_165; timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_165MHz; } } #endif #ifdef CONFIG_VIDEO_OMAP3 /* * Configure DSS to display background color on DVID * Configure VENC to display color bar on S-Video */ static void beagle_display_init(void) { omap3_dss_venc_config(&venc_config_std_tv, VENC_HEIGHT, VENC_WIDTH); omap3_dss_panel_config(&dvid_cfg_xm); } /* * Enable DVI power */ static void beagle_dvi_pup(void) { uchar val; #define GPIODATADIR1 (TWL4030_BASEADD_GPIO+3) #define GPIODATAOUT1 (TWL4030_BASEADD_GPIO+6) i2c_read(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1); val |= 4; i2c_write(TWL4030_CHIP_GPIO, GPIODATADIR1, 1, &val, 1); i2c_read(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1); val |= 4; i2c_write(TWL4030_CHIP_GPIO, GPIODATAOUT1, 1, &val, 1); } #endif #ifdef CONFIG_USB_MUSB_OMAP2PLUS static struct musb_hdrc_config musb_config = { .multipoint = 1, .dyn_fifo = 1, .num_eps = 16, .ram_bits = 12, }; static struct omap_musb_board_data musb_board_data = { .interface_type = MUSB_INTERFACE_ULPI, }; static struct musb_hdrc_platform_data musb_plat = { #if defined(CONFIG_MUSB_HOST) .mode = MUSB_HOST, #elif defined(CONFIG_MUSB_GADGET) .mode = MUSB_PERIPHERAL, #else #error "Please define either CONFIG_MUSB_HOST or CONFIG_MUSB_GADGET" #endif .config = &musb_config, .power = 100, .platform_ops = &omap2430_ops, .board_data = &musb_board_data, }; #endif /* * Routine: misc_init_r * Description: Configure board specific parts */ int misc_init_r(void) { struct gpio *gpio5_base = (struct gpio *)OMAP34XX_GPIO5_BASE; struct gpio *gpio6_base = (struct gpio *)OMAP34XX_GPIO6_BASE; struct control_prog_io *prog_io_base = (struct control_prog_io *)OMAP34XX_CTRL_BASE; /* Enable i2c2 pullup resisters */ writel(~(PRG_I2C2_PULLUPRESX), &prog_io_base->io1); printf("Olio H1\n"); setenv("beaglerev", "xMC"); MUX_BEAGLE_XM(); /* Set VAUX2 to 1.8V for EHCI PHY */ twl4030_pmrecv_vsel_cfg(TWL4030_PM_RECEIVER_VAUX2_DEDICATED, TWL4030_PM_RECEIVER_VAUX2_VSEL_18, TWL4030_PM_RECEIVER_VAUX2_DEV_GRP, TWL4030_PM_RECEIVER_DEV_GRP_P1); setenv("buddy", "none"); twl4030_power_init(); /* Set GPIO states before they are made outputs */ writel(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1, &gpio6_base->setdataout); writel(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 | GPIO15 | GPIO14 | GPIO13 | GPIO12, &gpio5_base->setdataout); /* Configure GPIOs to output */ writel(~(GPIO23 | GPIO10 | GPIO8 | GPIO2 | GPIO1), &gpio6_base->oe); writel(~(GPIO31 | GPIO30 | GPIO29 | GPIO28 | GPIO22 | GPIO21 | GPIO15 | GPIO14 | GPIO13 | GPIO12), &gpio5_base->oe); dieid_num_r(); #ifdef CONFIG_VIDEO_OMAP3 beagle_dvi_pup(); beagle_display_init(); omap3_dss_enable(); #endif #ifdef CONFIG_USB_MUSB_OMAP2PLUS musb_register(&musb_plat, &musb_board_data, (void *)MUSB_BASE); #endif return 0; } /* * Routine: set_muxconf_regs * Description: Setting up the configuration Mux registers specific to the * hardware. Many pins need to be moved from protect to primary * mode. */ void set_muxconf_regs(void) { MUX_BEAGLE(); } #if defined(CONFIG_USB_EHCI) && !defined(CONFIG_SPL_BUILD) /* Call usb_stop() before starting the kernel */ void show_boot_progress(int val) { if (val == BOOTSTAGE_ID_RUN_OS) usb_stop(); } static struct omap_usbhs_board_data usbhs_bdata = { .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY, .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY, .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED }; int ehci_hcd_init(int index, struct ehci_hccr **hccr, struct ehci_hcor **hcor) { return omap_ehci_hcd_init(&usbhs_bdata, hccr, hcor); } int ehci_hcd_stop(int index) { return omap_ehci_hcd_stop(); } #endif /* CONFIG_USB_EHCI */ #if defined(CONFIG_USB_ETHER) && defined(CONFIG_MUSB_GADGET) int board_eth_init(bd_t *bis) { return usb_eth_initialize(bis); } #endif