]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/memory/jz4780-nemc.c
Merge tag 'drm-misc-fixes-2019-11-25' of git://anongit.freedesktop.org/drm/drm-misc...
[linux.git] / drivers / memory / jz4780-nemc.c
index 698da973de35195651117400e16c02bf785391b1..b232ed279fc3924436b27564a981c08d6f1dcc74 100644 (file)
 #define NEMC_NFCSR_NFCEn(n)    BIT((((n) - 1) << 1) + 1)
 #define NEMC_NFCSR_TNFEn(n)    BIT(16 + (n) - 1)
 
+struct jz_soc_info {
+       u8 tas_tah_cycles_max;
+};
+
 struct jz4780_nemc {
        spinlock_t lock;
        struct device *dev;
+       const struct jz_soc_info *soc_info;
        void __iomem *base;
        struct clk *clk;
        uint32_t clk_period;
@@ -56,7 +61,7 @@ struct jz4780_nemc {
  *
  * Return: The number of unique NEMC banks referred to by the specified NEMC
  * child device. Unique here means that a device that references the same bank
- * multiple times in the its "reg" property will only count once.
+ * multiple times in its "reg" property will only count once.
  */
 unsigned int jz4780_nemc_num_banks(struct device *dev)
 {
@@ -158,7 +163,7 @@ static bool jz4780_nemc_configure_bank(struct jz4780_nemc *nemc,
         * Conversion of tBP and tAW cycle counts to values supported by the
         * hardware (round up to the next supported value).
         */
-       static const uint32_t convert_tBP_tAW[] = {
+       static const u8 convert_tBP_tAW[] = {
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
 
                /* 11 - 12 -> 12 cycles */
@@ -199,7 +204,7 @@ static bool jz4780_nemc_configure_bank(struct jz4780_nemc *nemc,
        if (of_property_read_u32(node, "ingenic,nemc-tAS", &val) == 0) {
                smcr &= ~NEMC_SMCR_TAS_MASK;
                cycles = jz4780_nemc_ns_to_cycles(nemc, val);
-               if (cycles > 15) {
+               if (cycles > nemc->soc_info->tas_tah_cycles_max) {
                        dev_err(nemc->dev, "tAS %u is too high (%u cycles)\n",
                                val, cycles);
                        return false;
@@ -211,7 +216,7 @@ static bool jz4780_nemc_configure_bank(struct jz4780_nemc *nemc,
        if (of_property_read_u32(node, "ingenic,nemc-tAH", &val) == 0) {
                smcr &= ~NEMC_SMCR_TAH_MASK;
                cycles = jz4780_nemc_ns_to_cycles(nemc, val);
-               if (cycles > 15) {
+               if (cycles > nemc->soc_info->tas_tah_cycles_max) {
                        dev_err(nemc->dev, "tAH %u is too high (%u cycles)\n",
                                val, cycles);
                        return false;
@@ -275,6 +280,10 @@ static int jz4780_nemc_probe(struct platform_device *pdev)
        if (!nemc)
                return -ENOMEM;
 
+       nemc->soc_info = device_get_match_data(dev);
+       if (!nemc->soc_info)
+               return -EINVAL;
+
        spin_lock_init(&nemc->lock);
        nemc->dev = dev;
 
@@ -367,8 +376,17 @@ static int jz4780_nemc_remove(struct platform_device *pdev)
        return 0;
 }
 
+static const struct jz_soc_info jz4740_soc_info = {
+       .tas_tah_cycles_max = 7,
+};
+
+static const struct jz_soc_info jz4780_soc_info = {
+       .tas_tah_cycles_max = 15,
+};
+
 static const struct of_device_id jz4780_nemc_dt_match[] = {
-       { .compatible = "ingenic,jz4780-nemc" },
+       { .compatible = "ingenic,jz4740-nemc", .data = &jz4740_soc_info, },
+       { .compatible = "ingenic,jz4780-nemc", .data = &jz4780_soc_info, },
        {},
 };