void board_init_f(ulong dummy) { struct udevice *pinctrl; struct udevice *dev; struct rk3399_pmusgrf_regs *sgrf; struct rk3399_grf_regs *grf; int ret; #define EARLY_UART #ifdef EARLY_UART /* * Debug UART can be used from here if required: * * debug_uart_init(); * printch('a'); * printhex8(0x1234); * printascii("string"); */ debug_uart_init(); printascii("U-Boot SPL board init"); #endif ret = spl_early_init(); if (ret) { debug("spl_early_init() failed: %d\n", ret); hang(); } /* * Disable DDR and SRAM security regions. * * As we are entered from the BootROM, the region from * 0x0 through 0xfffff (i.e. the first MB of memory) will * be protected. This will cause issues with the DW_MMC * driver, which tries to DMA from/to the stack (likely) * located in this range. */ sgrf = syscon_get_first_range(ROCKCHIP_SYSCON_PMUSGRF); rk_clrsetreg(&sgrf->ddr_rgn_con[16], 0x1ff, 0); rk_clrreg(&sgrf->slv_secure_con4, 0x2000); /* eMMC clock generator: disable the clock multipilier */ grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF); rk_clrreg(&grf->emmccore_con[11], 0x0ff); secure_timer_init(); ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl); if (ret) { debug("Pinctrl init failed: %d\n", ret); return; } ret = uclass_get_device(UCLASS_RAM, 0, &dev); if (ret) { debug("DRAM init failed: %d\n", ret); return; } }
static int rk3288_pinctrl_probe(struct udevice *dev) { struct rk3288_pinctrl_priv *priv = dev_get_priv(dev); int ret = 0; priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF); priv->pmu = syscon_get_first_range(ROCKCHIP_SYSCON_PMU); debug("%s: grf=%p, pmu=%p\n", __func__, priv->grf, priv->pmu); #ifndef CONFIG_SPL_BUILD ret = rk3288_pinctrl_parse_tables(priv, rk3288_pin_banks, ARRAY_SIZE(rk3288_pin_banks)); #endif return ret; }
static void rk3288_set_io_vsel(struct udevice *dev) { struct rk3288_grf *grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF); /* lcdc(vop) iodomain select 1.8V */ rk_setreg(&grf->io_vsel, 1 << 0); }
static int rv1108_pinctrl_probe(struct udevice *dev) { struct rv1108_pinctrl_priv *priv = dev_get_priv(dev); priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF); return 0; }
static int rk3036_pinctrl_probe(struct udevice *dev) { struct rk3036_pinctrl_priv *priv = dev_get_priv(dev); priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF); debug("%s: grf=%p\n", __func__, priv->grf); return 0; }
static int pmu_mid_probe(struct udevice *dev) { struct pmu_mid *pmu = dev_get_priv(dev); pmu->regs = syscon_get_first_range(X86_SYSCON_PMU); return 0; }
static int rk3128_dmc_probe(struct udevice *dev) { struct dram_info *priv = dev_get_priv(dev); priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF); debug("%s: grf=%p\n", __func__, priv->grf); priv->info.base = CONFIG_SYS_SDRAM_BASE; priv->info.size = rockchip_sdram_size( (phys_addr_t)&priv->grf->os_reg[1]); return 0; }
/* Test we can access a regmap through syscon */ static int dm_test_regmap_syscon(struct unit_test_state *uts) { struct regmap *map; map = syscon_get_regmap_by_driver_data(SYSCON0); ut_assertok_ptr(map); ut_asserteq(1, map->range_count); map = syscon_get_regmap_by_driver_data(SYSCON1); ut_assertok_ptr(map); ut_asserteq(4, map->range_count); map = syscon_get_regmap_by_driver_data(SYSCON_COUNT); ut_asserteq_ptr(ERR_PTR(-ENODEV), map); ut_asserteq(0x10, map_to_sysmem(syscon_get_first_range(SYSCON0))); ut_asserteq(0x20, map_to_sysmem(syscon_get_first_range(SYSCON1))); ut_asserteq_ptr(ERR_PTR(-ENODEV), syscon_get_first_range(SYSCON_COUNT)); return 0; }
static void setup_iodomain(void) { const u32 GRF_IO_VSEL_GPIO4CD_SHIFT = 3; struct rk3399_grf_regs *grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF); /* * Set bit 3 in GRF_IO_VSEL so PCIE_RST# works (pin GPIO4_C6). * Linux assumes that PCIE_RST# works out of the box as it probes * PCIe before loading the iodomain driver. */ rk_setreg(&grf->io_vsel, 1 << GRF_IO_VSEL_GPIO4CD_SHIFT); }
int board_late_init(void) { struct rk3188_grf *grf; grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF); if (IS_ERR(grf)) { pr_err("grf syscon returned %ld\n", PTR_ERR(grf)); } else { /* enable noc remap to mimic legacy loaders */ rk_clrsetreg(&grf->soc_con0, NOC_REMAP_MASK << NOC_REMAP_SHIFT, NOC_REMAP_MASK << NOC_REMAP_SHIFT); } return 0; }
static int rk_lvds_ofdata_to_platdata(struct udevice *dev) { struct rk_lvds_priv *priv = dev_get_priv(dev); const void *blob = gd->fdt_blob; int node = dev->of_offset; int ret; priv->regs = (void *)dev_get_addr(dev); priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF); ret = fdtdec_get_int(blob, node, "rockchip,output", -1); if (ret != -1) { priv->output = ret; debug("LVDS output : %d\n", ret); } else { /* default set it as output rgb */ priv->output = LVDS_OUTPUT_RGB; } ret = fdtdec_get_int(blob, node, "rockchip,data-mapping", -1); if (ret != -1) { priv->format = ret; debug("LVDS data-mapping : %d\n", ret); } else { /* default set it as format jeida */ priv->format = LVDS_FORMAT_JEIDA; } ret = fdtdec_get_int(blob, node, "rockchip,data-width", -1); if (ret != -1) { debug("LVDS data-width : %d\n", ret); if (ret == 24) { priv->format |= LVDS_24BIT; } else if (ret == 18) { priv->format |= LVDS_18BIT; } else { debug("rockchip-lvds unsupport data-width[%d]\n", ret); ret = -EINVAL; return ret; } } else { priv->format |= LVDS_24BIT; } return 0; }
static int tegra_sor_ofdata_to_platdata(struct udevice *dev) { struct tegra_dc_sor_data *priv = dev_get_priv(dev); int ret; priv->base = (void *)dev_read_addr(dev); priv->pmc_base = (void *)syscon_get_first_range(TEGRA_SYSCON_PMC); if (IS_ERR(priv->pmc_base)) return PTR_ERR(priv->pmc_base); ret = uclass_get_device_by_phandle(UCLASS_PANEL, dev, "nvidia,panel", &priv->panel); if (ret) { debug("%s: Cannot find panel for '%s' (ret=%d)\n", __func__, dev->name, ret); return ret; } return 0; }
void board_init_f(ulong dummy) { struct udevice *pinctrl, *dev; struct rk3188_pmu *pmu; int ret; /* Example code showing how to enable the debug UART on RK3188 */ #ifdef EARLY_UART #include <asm/arch/grf_rk3188.h> /* Enable early UART on the RK3188 */ #define GRF_BASE 0x20008000 struct rk3188_grf * const grf = (void *)GRF_BASE; rk_clrsetreg(&grf->gpio1b_iomux, GPIO1B1_MASK << GPIO1B1_SHIFT | GPIO1B0_MASK << GPIO1B0_SHIFT, GPIO1B1_UART2_SOUT << GPIO1B1_SHIFT | GPIO1B0_UART2_SIN << GPIO1B0_SHIFT); /* * Debug UART can be used from here if required: * * debug_uart_init(); * printch('a'); * printhex8(0x1234); * printascii("string"); */ debug_uart_init(); printch('s'); printch('p'); printch('l'); printch('\n'); #endif ret = spl_early_init(); if (ret) { debug("spl_early_init() failed: %d\n", ret); hang(); } rockchip_timer_init(); ret = rockchip_get_clk(&dev); if (ret) { debug("CLK init failed: %d\n", ret); return; } /* * Recover the bootrom's stackpointer. * For whatever reason needs to run after rockchip_get_clk. */ pmu = syscon_get_first_range(ROCKCHIP_SYSCON_PMU); if (IS_ERR(pmu)) error("pmu syscon returned %ld\n", PTR_ERR(pmu)); SAVE_SP_ADDR = readl(&pmu->sys_reg[2]); ret = uclass_get_device(UCLASS_PINCTRL, 0, &pinctrl); if (ret) { debug("Pinctrl init failed: %d\n", ret); return; } ret = uclass_get_device(UCLASS_RAM, 0, &dev); if (ret) { debug("DRAM init failed: %d\n", ret); return; } setup_arm_clock(); #if defined(CONFIG_ROCKCHIP_SPL_BACK_TO_BROM) && !defined(CONFIG_SPL_BOARD_INIT) back_to_bootrom(); #endif }
static int rk_vop_probe(struct udevice *dev) { struct video_uc_platdata *plat = dev_get_uclass_platdata(dev); const void *blob = gd->fdt_blob; struct rk_vop_priv *priv = dev_get_priv(dev); struct udevice *reg; int ret, port, node; /* Before relocation we don't need to do anything */ if (!(gd->flags & GD_FLG_RELOC)) return 0; priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF); priv->regs = (struct rk3288_vop *)dev_get_addr(dev); /* lcdc(vop) iodomain select 1.8V */ rk_setreg(&priv->grf->io_vsel, 1 << 0); /* * Try some common regulators. We should really get these from the * device tree somehow. */ ret = regulator_autoset_by_name("vcc18_lcd", ®); if (ret) debug("%s: Cannot autoset regulator vcc18_lcd\n", __func__); ret = regulator_autoset_by_name("VCC18_LCD", ®); if (ret) debug("%s: Cannot autoset regulator VCC18_LCD\n", __func__); ret = regulator_autoset_by_name("vdd10_lcd_pwren_h", ®); if (ret) { debug("%s: Cannot autoset regulator vdd10_lcd_pwren_h\n", __func__); } ret = regulator_autoset_by_name("vdd10_lcd", ®); if (ret) { debug("%s: Cannot autoset regulator vdd10_lcd\n", __func__); } ret = regulator_autoset_by_name("VDD10_LCD", ®); if (ret) { debug("%s: Cannot autoset regulator VDD10_LCD\n", __func__); } ret = regulator_autoset_by_name("vcc33_lcd", ®); if (ret) debug("%s: Cannot autoset regulator vcc33_lcd\n", __func__); /* * Try all the ports until we find one that works. In practice this * tries EDP first if available, then HDMI. */ port = fdt_subnode_offset(blob, dev->of_offset, "port"); if (port < 0) return -EINVAL; for (node = fdt_first_subnode(blob, port); node > 0; node = fdt_next_subnode(blob, node)) { ret = rk_display_init(dev, plat->base, VIDEO_BPP16, node); if (ret) debug("Device failed: ret=%d\n", ret); if (!ret) break; } return ret; }