long mon_get_count(int n, u32 start_val) { u32 overflow, count; count = get_l2_indirect_reg(L2PMnEVCNTR(n)); overflow = get_l2_indirect_reg(L2PMOVSR); pr_debug("EV%d ov: %x, cnt: %x\n", n, overflow, count); if (overflow & BIT(n)) return 0xFFFFFFFF - start_val + count; else return count - start_val; }
static irqreturn_t mon_intr_handler(int irq, void *dev) { struct devfreq *df = dev; ktime_t ts; unsigned int us; u32 regval; int ret; regval = get_l2_indirect_reg(L2PMOVSR); pr_debug("Got interrupt: %x\n", regval); devfreq_monitor_stop(df); ts = ktime_get(); us = ktime_to_us(ktime_sub(ts, prev_ts)); if (us > TOO_SOON_US) { mutex_lock(&df->lock); ret = update_devfreq(df); if (ret) pr_err("Unable to update freq on IRQ!\n"); mutex_unlock(&df->lock); } devfreq_monitor_start(df); return IRQ_HANDLED; }
static irqreturn_t mon_intr_handler(int irq, void *dev_id) { bool pending; u32 regval; regval = get_l2_indirect_reg(L2PMOVSR); pr_debug("Got interrupt: %x\n", regval); pending = cancel_delayed_work_sync(&bw_sample); /* * Don't recalc bandwidth if the interrupt came just after the end * of the sample period (!pending). This is done for two reasons: * * 1. Sampling the BW during a very short duration can result in a * very inaccurate measurement due to very short bursts. * 2. If the limit was hit very close to the sample period, then the * current BW estimate is not very off and can stay as such. */ if (pending) measure_bw(); queue_delayed_work(bw_sample_wq, &bw_sample, msecs_to_jiffies(sample_ms)); return IRQ_HANDLED; }
void clear_l2cache_err(void) { unsigned int val; val = get_l2_indirect_reg(L2ESR_IND_ADDR); #ifdef CONFIG_IPQ_REPORT_L2ERR report_l2err(val); #endif set_l2_indirect_reg(L2ESR_IND_ADDR, val); }
static void global_mon_enable(bool en) { u32 regval; regval = get_l2_indirect_reg(L2PMCR); if (en) regval |= BIT(0); else regval &= ~BIT(0); set_l2_indirect_reg(L2PMCR, regval); }
static void __set_pri_clk_src(struct scalable *sc, u32 pri_src_sel) { u32 regval; regval = get_l2_indirect_reg(sc->l2cpmr_iaddr); regval &= ~0x3; regval |= (pri_src_sel & 0x3); set_l2_indirect_reg(sc->l2cpmr_iaddr, regval); /* Wait for switch to complete. */ mb(); udelay(1); }
/* Returns MBps of read/writes for the sampling window. */ static int mon_get_mbps(int n, u32 start_val, unsigned int us) { u32 overflow, count; long long beats; count = get_l2_indirect_reg(L2PMnEVCNTR(n)); overflow = get_l2_indirect_reg(L2PMOVSR); if (overflow & BIT(n)) beats = 0xFFFFFFFF - start_val + count; else beats = count - start_val; beats *= USEC_PER_SEC; beats *= bytes_per_beat; do_div(beats, us); beats = DIV_ROUND_UP_ULL(beats, MBYTE); pr_debug("EV%d ov: %x, cnt: %x\n", n, overflow, count); return beats; }
static void __set_pri_clk_src(struct scalable *sc, u32 pri_src_sel) { u32 regval; regval = get_l2_indirect_reg(sc->l2cpmr_iaddr); regval &= ~0x3; regval |= pri_src_sel; if (sc != &drv.scalable[L2]) { regval &= ~(0x3 << 8); regval |= pri_src_sel << 8; } set_l2_indirect_reg(sc->l2cpmr_iaddr, regval); /* Wait for switch to complete. */ mb(); udelay(1); }
static irqreturn_t mon_intr_handler(int irq, void *dev) { struct devfreq *df = dev; ktime_t ts; unsigned int us; u32 regval; int ret; regval = get_l2_indirect_reg(L2PMOVSR); pr_debug("Got interrupt: %x\n", regval); devfreq_monitor_stop(df); /* * Don't recalc bandwidth if the interrupt comes right after a * previous bandwidth calculation. This is done for two reasons: * * 1. Sampling the BW during a very short duration can result in a * very inaccurate measurement due to very short bursts. * 2. This can only happen if the limit was hit very close to the end * of the previous sample period. Which means the current BW * estimate is not very off and doesn't need to be readjusted. */ ts = ktime_get(); us = ktime_to_us(ktime_sub(ts, prev_ts)); if (us > TOO_SOON_US) { mutex_lock(&df->lock); ret = update_devfreq(df); if (ret) pr_err("Unable to update freq on IRQ!\n"); mutex_unlock(&df->lock); } devfreq_monitor_start(df); return IRQ_HANDLED; }
int board_init() { int ret; uint32_t start_blocks; uint32_t size_blocks; #ifdef CONFIG_IPQ_REPORT_L2ERR u32 l2esr; /* Record any kind of L2 errors caused during * the previous boot stages as we are clearing * the L2 errors before jumping to linux. * Refer to cleanup_before_linux() */ l2esr = get_l2_indirect_reg(L2ESR_IND_ADDR); report_l2err(l2esr); #endif ipq_smem_flash_info_t *sfi = &ipq_smem_flash_info; /* * after relocation gboard_param is reset to NULL * initialize again */ gd->bd->bi_boot_params = IPQ_BOOT_PARAMS_ADDR; gd->bd->bi_arch_number = smem_get_board_machtype(); gboard_param = get_board_param(gd->bd->bi_arch_number); ret = smem_get_boot_flash(&sfi->flash_type, &sfi->flash_index, &sfi->flash_chip_select, &sfi->flash_block_size); if (ret < 0) { printf("cdp: get boot flash failed\n"); return ret; } /* * Should be inited, before env_relocate() is called, * since env. offset is obtained from SMEM. */ if (sfi->flash_type != SMEM_BOOT_MMC_FLASH) { ret = smem_ptable_init(); if (ret < 0) { printf("cdp: SMEM init failed\n"); return ret; } } if (sfi->flash_type == SMEM_BOOT_NAND_FLASH) { nand_env_device = CONFIG_IPQ_NAND_NAND_INFO_IDX; } else if (sfi->flash_type == SMEM_BOOT_SPI_FLASH) { nand_env_device = CONFIG_IPQ_SPI_NAND_INFO_IDX; #ifdef CONFIG_IPQ_MMC if (gd->bd->bi_arch_number == MACH_TYPE_IPQ806X_AP145_1XX ) { gboard_param->emmc_gpio = emmc1_gpio; gboard_param->emmc_gpio_count = ARRAY_SIZE(emmc1_gpio); } } else if (sfi->flash_type == SMEM_BOOT_MMC_FLASH) { gboard_param->emmc_gpio = emmc1_gpio; gboard_param->emmc_gpio_count = ARRAY_SIZE(emmc1_gpio); #endif } else { printf("BUG: unsupported flash type : %d\n", sfi->flash_type); BUG(); } if (sfi->flash_type != SMEM_BOOT_MMC_FLASH) { ret = smem_getpart("0:APPSBLENV", &start_blocks, &size_blocks); if (ret < 0) { printf("cdp: get environment part failed\n"); return ret; } board_env_offset = ((loff_t) sfi->flash_block_size) * start_blocks; board_env_size = ((loff_t) sfi->flash_block_size) * size_blocks; } if (sfi->flash_type == SMEM_BOOT_NAND_FLASH) { board_env_range = CONFIG_ENV_SIZE_MAX; BUG_ON(board_env_size < CONFIG_ENV_SIZE_MAX); } else if (sfi->flash_type == SMEM_BOOT_SPI_FLASH) { board_env_range = board_env_size; BUG_ON(board_env_size > CONFIG_ENV_SIZE_MAX); #ifdef CONFIG_IPQ_MMC } else if (sfi->flash_type == SMEM_BOOT_MMC_FLASH) { board_env_range = CONFIG_ENV_SIZE_MAX; #endif } else { printf("BUG: unsupported flash type : %d\n", sfi->flash_type); BUG(); } if (sfi->flash_type != SMEM_BOOT_MMC_FLASH) { saveenv = nand_saveenv; env_ptr = nand_env_ptr; env_name_spec = nand_env_name_spec; #ifdef CONFIG_IPQ_MMC } else { saveenv = mmc_saveenv; env_ptr = mmc_env_ptr; env_name_spec = mmc_env_name_spec; #endif } return 0; }