root/arch/nds32/kernel/atl2c.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. atl2c_of_init

   1 // SPDX-License-Identifier: GPL-2.0
   2 // Copyright (C) 2005-2017 Andes Technology Corporation
   3 
   4 #include <linux/compiler.h>
   5 #include <linux/of_address.h>
   6 #include <linux/of_fdt.h>
   7 #include <linux/of_platform.h>
   8 #include <asm/l2_cache.h>
   9 
  10 void __iomem *atl2c_base;
  11 static const struct of_device_id atl2c_ids[] __initconst = {
  12         {.compatible = "andestech,atl2c",},
  13         {}
  14 };
  15 
  16 static int __init atl2c_of_init(void)
  17 {
  18         struct device_node *np;
  19         struct resource res;
  20         unsigned long tmp = 0;
  21         unsigned long l2set, l2way, l2clsz;
  22 
  23         if (!(__nds32__mfsr(NDS32_SR_MSC_CFG) & MSC_CFG_mskL2C))
  24                 return -ENODEV;
  25 
  26         np = of_find_matching_node(NULL, atl2c_ids);
  27         if (!np)
  28                 return -ENODEV;
  29 
  30         if (of_address_to_resource(np, 0, &res))
  31                 return -ENODEV;
  32 
  33         atl2c_base = ioremap(res.start, resource_size(&res));
  34         if (!atl2c_base)
  35                 return -ENOMEM;
  36 
  37         l2set =
  38             64 << ((L2C_R_REG(L2_CA_CONF_OFF) & L2_CA_CONF_mskL2SET) >>
  39                    L2_CA_CONF_offL2SET);
  40         l2way =
  41             1 +
  42             ((L2C_R_REG(L2_CA_CONF_OFF) & L2_CA_CONF_mskL2WAY) >>
  43              L2_CA_CONF_offL2WAY);
  44         l2clsz =
  45             4 << ((L2C_R_REG(L2_CA_CONF_OFF) & L2_CA_CONF_mskL2CLSZ) >>
  46                   L2_CA_CONF_offL2CLSZ);
  47         pr_info("L2:%luKB/%luS/%luW/%luB\n",
  48                 l2set * l2way * l2clsz / 1024, l2set, l2way, l2clsz);
  49 
  50         tmp = L2C_R_REG(L2CC_PROT_OFF);
  51         tmp &= ~L2CC_PROT_mskMRWEN;
  52         L2C_W_REG(L2CC_PROT_OFF, tmp);
  53 
  54         tmp = L2C_R_REG(L2CC_SETUP_OFF);
  55         tmp &= ~L2CC_SETUP_mskPART;
  56         L2C_W_REG(L2CC_SETUP_OFF, tmp);
  57 
  58         tmp = L2C_R_REG(L2CC_CTRL_OFF);
  59         tmp |= L2CC_CTRL_mskEN;
  60         L2C_W_REG(L2CC_CTRL_OFF, tmp);
  61 
  62         return 0;
  63 }
  64 
  65 subsys_initcall(atl2c_of_init);

/* [<][>][^][v][top][bottom][index][help] */