]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Merge remote-tracking branch 'dt-rh/for-next'
authorThierry Reding <treding@nvidia.com>
Thu, 24 Oct 2013 12:37:24 +0000 (14:37 +0200)
committerThierry Reding <treding@nvidia.com>
Thu, 24 Oct 2013 12:37:24 +0000 (14:37 +0200)
20 files changed:
1  2 
arch/arm/mm/init.c
arch/mips/ralink/of.c
arch/powerpc/platforms/8xx/tqm8xx_setup.c
arch/powerpc/platforms/powernv/opal.c
arch/powerpc/sysdev/mpic.c
drivers/cpufreq/pasemi-cpufreq.c
drivers/crypto/caam/ctrl.c
drivers/crypto/talitos.c
drivers/mtd/nand/fsl_elbc_nand.c
drivers/mtd/nand/fsl_ifc_nand.c
drivers/net/ethernet/freescale/gianfar.c
drivers/net/ethernet/freescale/ucc_geth.c
drivers/net/ethernet/ibm/emac/core.c
drivers/net/ethernet/xilinx/ll_temac_main.c
drivers/of/address.c
drivers/of/base.c
drivers/of/fdt.c
drivers/spi/spi-mpc512x-psc.c
sound/soc/fsl/fsl_dma.c
sound/soc/fsl/mpc5200_dma.c

diff --combined arch/arm/mm/init.c
index 2a3fa425c52c4062addaf897951d3b8265819764,9d0b91dccf379cd442a32774a99738805f74745e..3e8f106ee5fe01855fe12f66b0c581822c0521da
@@@ -17,6 -17,7 +17,6 @@@
  #include <linux/nodemask.h>
  #include <linux/initrd.h>
  #include <linux/of_fdt.h>
 -#include <linux/of_reserved_mem.h>
  #include <linux/highmem.h>
  #include <linux/gfp.h>
  #include <linux/memblock.h>
@@@ -76,14 -77,6 +76,6 @@@ static int __init parse_tag_initrd2(con
  
  __tagtable(ATAG_INITRD2, parse_tag_initrd2);
  
- #ifdef CONFIG_OF_FLATTREE
- void __init early_init_dt_setup_initrd_arch(u64 start, u64 end)
- {
-       phys_initrd_start = start;
-       phys_initrd_size = end - start;
- }
- #endif /* CONFIG_OF_FLATTREE */
  /*
   * This keeps memory configuration data used by a couple memory
   * initialization functions, as well as show_mem() for the skipping
@@@ -217,7 -210,6 +209,7 @@@ EXPORT_SYMBOL(arm_dma_zone_size)
   * so a successful GFP_DMA allocation will always satisfy this.
   */
  phys_addr_t arm_dma_limit;
 +unsigned long arm_dma_pfn_limit;
  
  static void __init arm_adjust_dma_zone(unsigned long *size, unsigned long *hole,
        unsigned long dma_size)
@@@ -240,7 -232,6 +232,7 @@@ void __init setup_dma_zone(const struc
                arm_dma_limit = PHYS_OFFSET + arm_dma_zone_size - 1;
        } else
                arm_dma_limit = 0xffffffff;
 +      arm_dma_pfn_limit = arm_dma_limit >> PAGE_SHIFT;
  #endif
  }
  
@@@ -352,6 -343,11 +344,11 @@@ void __init arm_memblock_init(struct me
        memblock_reserve(__pa(_stext), _end - _stext);
  #endif
  #ifdef CONFIG_BLK_DEV_INITRD
+       /* FDT scan will populate initrd_start */
+       if (initrd_start) {
+               phys_initrd_start = __virt_to_phys(initrd_start);
+               phys_initrd_size = initrd_end - initrd_start;
+       }
        if (phys_initrd_size &&
            !memblock_is_region_memory(phys_initrd_start, phys_initrd_size)) {
                pr_err("INITRD: 0x%08llx+0x%08lx is not a memory region - disabling initrd\n",
        if (mdesc->reserve)
                mdesc->reserve();
  
 -      early_init_dt_scan_reserved_mem();
 -
        /*
         * reserve memory for DMA contigouos allocations,
         * must come from DMA area inside low memory
@@@ -423,10 -421,12 +420,10 @@@ void __init bootmem_init(void
         * This doesn't seem to be used by the Linux memory manager any
         * more, but is used by ll_rw_block.  If we can get rid of it, we
         * also get rid of some of the stuff above as well.
 -       *
 -       * Note: max_low_pfn and max_pfn reflect the number of _pages_ in
 -       * the system, not the maximum PFN.
         */
 -      max_low_pfn = max_low - PHYS_PFN_OFFSET;
 -      max_pfn = max_high - PHYS_PFN_OFFSET;
 +      min_low_pfn = min;
 +      max_low_pfn = max_low;
 +      max_pfn = max_high;
  }
  
  /*
@@@ -532,7 -532,7 +529,7 @@@ static inline void free_area_high(unsig
  static void __init free_highpages(void)
  {
  #ifdef CONFIG_HIGHMEM
 -      unsigned long max_low = max_low_pfn + PHYS_PFN_OFFSET;
 +      unsigned long max_low = max_low_pfn;
        struct memblock_region *mem, *res;
  
        /* set highmem page free */
diff --combined arch/mips/ralink/of.c
index 15f21ea96121023b60d005045a3115bac48c5622,58c4fd52202e7626df5dc1be7f7e06b249459113..eccc5526155e1b776acc87b35563d89ef72d5ea5
@@@ -21,6 -21,7 +21,7 @@@
  #include <asm/reboot.h>
  #include <asm/bootinfo.h>
  #include <asm/addrspace.h>
+ #include <asm/prom.h>
  
  #include "common.h"
  
@@@ -108,7 -109,7 +109,7 @@@ static int __init plat_of_setup(void
        strncpy(of_ids[1].compatible, "palmbus", len);
  
        if (of_platform_populate(NULL, of_ids, NULL, NULL))
 -              panic("failed to populate DT\n");
 +              panic("failed to populate DT");
  
        /* make sure ithat the reset controller is setup early */
        ralink_rst_init();
index ef0778a0ca8f996ef0b8d6c86a032c6eb05899f7,c9a0d00a98ab421898cb3cc83e60b95e449a7111..251aba8759e40bf11075add0ef43c232942763c8
@@@ -28,6 -28,7 +28,7 @@@
  #include <linux/fs_uart_pd.h>
  #include <linux/fsl_devices.h>
  #include <linux/mii.h>
+ #include <linux/of_fdt.h>
  #include <linux/of_platform.h>
  
  #include <asm/delay.h>
@@@ -48,7 -49,7 +49,7 @@@ struct cpm_pin 
        int port, pin, flags;
  };
  
 -static struct __initdata cpm_pin tqm8xx_pins[] = {
 +static struct cpm_pin tqm8xx_pins[] __initdata = {
        /* SMC1 */
        {CPM_PORTB, 24, CPM_PIN_INPUT}, /* RX */
        {CPM_PORTB, 25, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */
@@@ -63,7 -64,7 +64,7 @@@
        {CPM_PORTC, 11, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO},
  };
  
 -static struct __initdata cpm_pin tqm8xx_fec_pins[] = {
 +static struct cpm_pin tqm8xx_fec_pins[] __initdata = {
        /* MII */
        {CPM_PORTD, 3, CPM_PIN_OUTPUT},
        {CPM_PORTD, 4, CPM_PIN_OUTPUT},
index 09336f0c54c56e12954b454f6d562aac64508c50,f36ff3518c07eaf9de6d595a409733c29a514f76..329924f76a7161be23d521459178f826636d6115
@@@ -13,6 -13,7 +13,7 @@@
  
  #include <linux/types.h>
  #include <linux/of.h>
+ #include <linux/of_fdt.h>
  #include <linux/of_platform.h>
  #include <linux/interrupt.h>
  #include <linux/notifier.h>
@@@ -77,7 -78,6 +78,7 @@@ int __init early_init_dt_scan_opal(unsi
  
  static int __init opal_register_exception_handlers(void)
  {
 +#ifdef __BIG_ENDIAN__
        u64 glue;
  
        if (!(powerpc_firmware_features & FW_FEATURE_OPAL))
@@@ -95,7 -95,6 +96,7 @@@
                                        0, glue);
        glue += 128;
        opal_register_exception_handler(OPAL_SOFTPATCH_HANDLER, 0, glue);
 +#endif
  
        return 0;
  }
@@@ -166,28 -165,27 +167,28 @@@ void opal_notifier_disable(void
  
  int opal_get_chars(uint32_t vtermno, char *buf, int count)
  {
 -      s64 len, rc;
 -      u64 evt;
 +      s64 rc;
 +      __be64 evt, len;
  
        if (!opal.entry)
                return -ENODEV;
        opal_poll_events(&evt);
 -      if ((evt & OPAL_EVENT_CONSOLE_INPUT) == 0)
 +      if ((be64_to_cpu(evt) & OPAL_EVENT_CONSOLE_INPUT) == 0)
                return 0;
 -      len = count;
 -      rc = opal_console_read(vtermno, &len, buf);
 +      len = cpu_to_be64(count);
 +      rc = opal_console_read(vtermno, &len, buf);     
        if (rc == OPAL_SUCCESS)
 -              return len;
 +              return be64_to_cpu(len);
        return 0;
  }
  
  int opal_put_chars(uint32_t vtermno, const char *data, int total_len)
  {
        int written = 0;
 +      __be64 olen;
        s64 len, rc;
        unsigned long flags;
 -      u64 evt;
 +      __be64 evt;
  
        if (!opal.entry)
                return -ENODEV;
         */
        spin_lock_irqsave(&opal_write_lock, flags);
        if (firmware_has_feature(FW_FEATURE_OPALv2)) {
 -              rc = opal_console_write_buffer_space(vtermno, &len);
 +              rc = opal_console_write_buffer_space(vtermno, &olen);
 +              len = be64_to_cpu(olen);
                if (rc || len < total_len) {
                        spin_unlock_irqrestore(&opal_write_lock, flags);
                        /* Closed -> drop characters */
                        if (rc)
                                return total_len;
 -                      opal_poll_events(&evt);
 +                      opal_poll_events(NULL);
                        return -EAGAIN;
                }
        }
        rc = OPAL_BUSY;
        while(total_len > 0 && (rc == OPAL_BUSY ||
                                rc == OPAL_BUSY_EVENT || rc == OPAL_SUCCESS)) {
 -              len = total_len;
 -              rc = opal_console_write(vtermno, &len, data);
 +              olen = cpu_to_be64(total_len);
 +              rc = opal_console_write(vtermno, &olen, data);
 +              len = be64_to_cpu(olen);
  
                /* Closed or other error drop */
                if (rc != OPAL_SUCCESS && rc != OPAL_BUSY &&
                 */
                do
                        opal_poll_events(&evt);
 -              while(rc == OPAL_SUCCESS && (evt & OPAL_EVENT_CONSOLE_OUTPUT));
 +              while(rc == OPAL_SUCCESS &&
 +                      (be64_to_cpu(evt) & OPAL_EVENT_CONSOLE_OUTPUT));
        }
        spin_unlock_irqrestore(&opal_write_lock, flags);
        return written;
@@@ -366,7 -361,7 +367,7 @@@ int opal_machine_check(struct pt_regs *
  
  static irqreturn_t opal_interrupt(int irq, void *data)
  {
 -      uint64_t events;
 +      __be64 events;
  
        opal_handle_interrupt(virq_to_hw(irq), &events);
  
  static int __init opal_init(void)
  {
        struct device_node *np, *consoles;
 -      const u32 *irqs;
 +      const __be32 *irqs;
        int rc, i, irqlen;
  
        opal_node = of_find_node_by_path("/ibm,opal");
index bdcb8588e4926c42130935a0ef33d2d19cab4b99,2d30eafc40d8794f301aabe56253d504bf3ed727..0e166ed4cd16b7452f2656501de27c4f085e02da
@@@ -535,7 -535,7 +535,7 @@@ static void __init mpic_scan_ht_pic(str
                mpic->fixups[irq].data = readl(base + 4) | 0x80000000;
        }
  }
-  
  
  static void __init mpic_scan_ht_pics(struct mpic *mpic)
  {
@@@ -1088,14 -1088,8 +1088,14 @@@ static int mpic_host_map(struct irq_dom
         * is done here.
         */
        if (!mpic_is_ipi(mpic, hw) && (mpic->flags & MPIC_NO_RESET)) {
 +              int cpu;
 +
 +              preempt_disable();
 +              cpu = mpic_processor_id(mpic);
 +              preempt_enable();
 +
                mpic_set_vector(virq, hw);
 -              mpic_set_destination(virq, mpic_processor_id(mpic));
 +              mpic_set_destination(virq, cpu);
                mpic_irq_set_priority(virq, 8);
        }
  
@@@ -1481,7 -1475,7 +1481,7 @@@ struct mpic * __init mpic_alloc(struct 
         * as a default instead of the value read from the HW.
         */
        last_irq = (greg_feature & MPIC_GREG_FEATURE_LAST_SRC_MASK)
-                               >> MPIC_GREG_FEATURE_LAST_SRC_SHIFT;    
+                               >> MPIC_GREG_FEATURE_LAST_SRC_SHIFT;
        if (isu_size)
                last_irq = isu_size  * MPIC_MAX_ISU - 1;
        of_property_read_u32(mpic->node, "last-interrupt-source", &last_irq);
@@@ -1631,7 -1625,7 +1631,7 @@@ void __init mpic_init(struct mpic *mpic
                        /* start with vector = source number, and masked */
                        u32 vecpri = MPIC_VECPRI_MASK | i |
                                (8 << MPIC_VECPRI_PRIORITY_SHIFT);
-               
                        /* check if protected */
                        if (mpic->protected && test_bit(i, mpic->protected))
                                continue;
                        mpic_irq_write(i, MPIC_INFO(IRQ_DESTINATION), 1 << cpu);
                }
        }
-       
        /* Init spurious vector */
        mpic_write(mpic->gregs, MPIC_INFO(GREG_SPURIOUS), mpic->spurious_vec);
  
index 1cca332728c3c36e2a40a5bc248f1cb39651c741,f4ec8145b3d18bf87a2928fecfe302a0a7491562..b05837730c3c82f399068e9675111817016e1637
@@@ -28,6 -28,7 +28,7 @@@
  #include <linux/cpufreq.h>
  #include <linux/timer.h>
  #include <linux/module.h>
+ #include <linux/of_address.h>
  
  #include <asm/hw_irq.h>
  #include <asm/io.h>
@@@ -69,6 -70,11 +70,6 @@@ static struct cpufreq_frequency_table p
        {0,     CPUFREQ_TABLE_END},
  };
  
 -static struct freq_attr *pas_cpu_freqs_attr[] = {
 -      &cpufreq_freq_attr_scaling_available_freqs,
 -      NULL,
 -};
 -
  /*
   * hardware specific functions
   */
@@@ -204,13 -210,22 +205,13 @@@ static int pas_cpufreq_cpu_init(struct 
                pr_debug("%d: %d\n", i, pas_freqs[i].frequency);
        }
  
 -      policy->cpuinfo.transition_latency = get_gizmo_latency();
 -
        cur_astate = get_cur_astate(policy->cpu);
        pr_debug("current astate is at %d\n",cur_astate);
  
        policy->cur = pas_freqs[cur_astate].frequency;
 -      cpumask_copy(policy->cpus, cpu_online_mask);
 -
        ppc_proc_freq = policy->cur * 1000ul;
  
 -      cpufreq_frequency_table_get_attr(pas_freqs, policy->cpu);
 -
 -      /* this ensures that policy->cpuinfo_min and policy->cpuinfo_max
 -       * are set correctly
 -       */
 -      return cpufreq_frequency_table_cpuinfo(policy, pas_freqs);
 +      return cpufreq_generic_init(policy, pas_freqs, get_gizmo_latency());
  
  out_unmap_sdcpwr:
        iounmap(sdcpwr_mapbase);
@@@ -239,6 -254,11 +240,6 @@@ static int pas_cpufreq_cpu_exit(struct 
        return 0;
  }
  
 -static int pas_cpufreq_verify(struct cpufreq_policy *policy)
 -{
 -      return cpufreq_frequency_table_verify(policy, pas_freqs);
 -}
 -
  static int pas_cpufreq_target(struct cpufreq_policy *policy,
                              unsigned int target_freq,
                              unsigned int relation)
@@@ -281,9 -301,9 +282,9 @@@ static struct cpufreq_driver pas_cpufre
        .flags          = CPUFREQ_CONST_LOOPS,
        .init           = pas_cpufreq_cpu_init,
        .exit           = pas_cpufreq_cpu_exit,
 -      .verify         = pas_cpufreq_verify,
 +      .verify         = cpufreq_generic_frequency_table_verify,
        .target         = pas_cpufreq_target,
 -      .attr           = pas_cpu_freqs_attr,
 +      .attr           = cpufreq_generic_attr,
  };
  
  /*
index 26438cd126859e75638c893ad6e959c3baf9e9ef,30548701665c8b1cbfc664ae5376e3b38e726b1d..5e7c7614c8fc1781301caa111a6d53dfd80159fd
@@@ -5,6 -5,9 +5,9 @@@
   * Copyright 2008-2012 Freescale Semiconductor, Inc.
   */
  
+ #include <linux/of_address.h>
+ #include <linux/of_irq.h>
  #include "compat.h"
  #include "regs.h"
  #include "intern.h"
  #include "error.h"
  #include "ctrl.h"
  
 -static int caam_remove(struct platform_device *pdev)
 -{
 -      struct device *ctrldev;
 -      struct caam_drv_private *ctrlpriv;
 -      struct caam_drv_private_jr *jrpriv;
 -      struct caam_full __iomem *topregs;
 -      int ring, ret = 0;
 -
 -      ctrldev = &pdev->dev;
 -      ctrlpriv = dev_get_drvdata(ctrldev);
 -      topregs = (struct caam_full __iomem *)ctrlpriv->ctrl;
 -
 -      /* shut down JobRs */
 -      for (ring = 0; ring < ctrlpriv->total_jobrs; ring++) {
 -              ret |= caam_jr_shutdown(ctrlpriv->jrdev[ring]);
 -              jrpriv = dev_get_drvdata(ctrlpriv->jrdev[ring]);
 -              irq_dispose_mapping(jrpriv->irq);
 -      }
 -
 -      /* Shut down debug views */
 -#ifdef CONFIG_DEBUG_FS
 -      debugfs_remove_recursive(ctrlpriv->dfs_root);
 -#endif
 -
 -      /* Unmap controller region */
 -      iounmap(&topregs->ctrl);
 -
 -      kfree(ctrlpriv->jrdev);
 -      kfree(ctrlpriv);
 -
 -      return ret;
 -}
 -
  /*
   * Descriptor to instantiate RNG State Handle 0 in normal mode and
   * load the JDKEK, TDKEK and TDSK registers
   */
 -static void build_instantiation_desc(u32 *desc)
 +static void build_instantiation_desc(u32 *desc, int handle, int do_sk)
  {
 -      u32 *jump_cmd;
 +      u32 *jump_cmd, op_flags;
  
        init_job_desc(desc, 0);
  
 +      op_flags = OP_TYPE_CLASS1_ALG | OP_ALG_ALGSEL_RNG |
 +                      (handle << OP_ALG_AAI_SHIFT) | OP_ALG_AS_INIT;
 +
        /* INIT RNG in non-test mode */
 -      append_operation(desc, OP_TYPE_CLASS1_ALG | OP_ALG_ALGSEL_RNG |
 -                       OP_ALG_AS_INIT);
 +      append_operation(desc, op_flags);
 +
 +      if (!handle && do_sk) {
 +              /*
 +               * For SH0, Secure Keys must be generated as well
 +               */
 +
 +              /* wait for done */
 +              jump_cmd = append_jump(desc, JUMP_CLASS_CLASS1);
 +              set_jump_tgt_here(desc, jump_cmd);
 +
 +              /*
 +               * load 1 to clear written reg:
 +               * resets the done interrrupt and returns the RNG to idle.
 +               */
 +              append_load_imm_u32(desc, 1, LDST_SRCDST_WORD_CLRW);
 +
 +              /* Initialize State Handle  */
 +              append_operation(desc, OP_TYPE_CLASS1_ALG | OP_ALG_ALGSEL_RNG |
 +                               OP_ALG_AAI_RNG4_SK);
 +      }
  
 -      /* wait for done */
 -      jump_cmd = append_jump(desc, JUMP_CLASS_CLASS1);
 -      set_jump_tgt_here(desc, jump_cmd);
 +      append_jump(desc, JUMP_CLASS_CLASS1 | JUMP_TYPE_HALT);
 +}
  
 -      /*
 -       * load 1 to clear written reg:
 -       * resets the done interrupt and returns the RNG to idle.
 -       */
 -      append_load_imm_u32(desc, 1, LDST_SRCDST_WORD_CLRW);
 +/* Descriptor for deinstantiation of State Handle 0 of the RNG block. */
 +static void build_deinstantiation_desc(u32 *desc, int handle)
 +{
 +      init_job_desc(desc, 0);
  
 -      /* generate secure keys (non-test) */
 +      /* Uninstantiate State Handle 0 */
        append_operation(desc, OP_TYPE_CLASS1_ALG | OP_ALG_ALGSEL_RNG |
 -                       OP_ALG_RNG4_SK);
 +                       (handle << OP_ALG_AAI_SHIFT) | OP_ALG_AS_INITFINAL);
 +
 +      append_jump(desc, JUMP_CLASS_CLASS1 | JUMP_TYPE_HALT);
  }
  
 -static int instantiate_rng(struct device *ctrldev)
 +/*
 + * run_descriptor_deco0 - runs a descriptor on DECO0, under direct control of
 + *                      the software (no JR/QI used).
 + * @ctrldev - pointer to device
 + * @status - descriptor status, after being run
 + *
 + * Return: - 0 if no error occurred
 + *       - -ENODEV if the DECO couldn't be acquired
 + *       - -EAGAIN if an error occurred while executing the descriptor
 + */
 +static inline int run_descriptor_deco0(struct device *ctrldev, u32 *desc,
 +                                      u32 *status)
  {
        struct caam_drv_private *ctrlpriv = dev_get_drvdata(ctrldev);
        struct caam_full __iomem *topregs;
        unsigned int timeout = 100000;
 -      u32 *desc;
 -      int i, ret = 0;
 -
 -      desc = kmalloc(CAAM_CMD_SZ * 6, GFP_KERNEL | GFP_DMA);
 -      if (!desc) {
 -              dev_err(ctrldev, "can't allocate RNG init descriptor memory\n");
 -              return -ENOMEM;
 -      }
 -      build_instantiation_desc(desc);
 +      u32 deco_dbg_reg, flags;
 +      int i;
  
        /* Set the bit to request direct access to DECO0 */
        topregs = (struct caam_full __iomem *)ctrlpriv->ctrl;
  
        if (!timeout) {
                dev_err(ctrldev, "failed to acquire DECO 0\n");
 -              ret = -EIO;
 -              goto out;
 +              clrbits32(&topregs->ctrl.deco_rq, DECORR_RQD0ENABLE);
 +              return -ENODEV;
        }
  
        for (i = 0; i < desc_len(desc); i++)
 -              topregs->deco.descbuf[i] = *(desc + i);
 +              wr_reg32(&topregs->deco.descbuf[i], *(desc + i));
  
 -      wr_reg32(&topregs->deco.jr_ctl_hi, DECO_JQCR_WHL | DECO_JQCR_FOUR);
 +      flags = DECO_JQCR_WHL;
 +      /*
 +       * If the descriptor length is longer than 4 words, then the
 +       * FOUR bit in JRCTRL register must be set.
 +       */
 +      if (desc_len(desc) >= 4)
 +              flags |= DECO_JQCR_FOUR;
 +
 +      /* Instruct the DECO to execute it */
 +      wr_reg32(&topregs->deco.jr_ctl_hi, flags);
  
        timeout = 10000000;
 -      while ((rd_reg32(&topregs->deco.desc_dbg) & DECO_DBG_VALID) &&
 -                                                               --timeout)
 +      do {
 +              deco_dbg_reg = rd_reg32(&topregs->deco.desc_dbg);
 +              /*
 +               * If an error occured in the descriptor, then
 +               * the DECO status field will be set to 0x0D
 +               */
 +              if ((deco_dbg_reg & DESC_DBG_DECO_STAT_MASK) ==
 +                  DESC_DBG_DECO_STAT_HOST_ERR)
 +                      break;
                cpu_relax();
 +      } while ((deco_dbg_reg & DESC_DBG_DECO_STAT_VALID) && --timeout);
  
 -      if (!timeout) {
 -              dev_err(ctrldev, "failed to instantiate RNG\n");
 -              ret = -EIO;
 -      }
 +      *status = rd_reg32(&topregs->deco.op_status_hi) &
 +                DECO_OP_STATUS_HI_ERR_MASK;
  
 +      /* Mark the DECO as free */
        clrbits32(&topregs->ctrl.deco_rq, DECORR_RQD0ENABLE);
 -out:
 +
 +      if (!timeout)
 +              return -EAGAIN;
 +
 +      return 0;
 +}
 +
 +/*
 + * instantiate_rng - builds and executes a descriptor on DECO0,
 + *                 which initializes the RNG block.
 + * @ctrldev - pointer to device
 + * @state_handle_mask - bitmask containing the instantiation status
 + *                    for the RNG4 state handles which exist in
 + *                    the RNG4 block: 1 if it's been instantiated
 + *                    by an external entry, 0 otherwise.
 + * @gen_sk  - generate data to be loaded into the JDKEK, TDKEK and TDSK;
 + *          Caution: this can be done only once; if the keys need to be
 + *          regenerated, a POR is required
 + *
 + * Return: - 0 if no error occurred
 + *       - -ENOMEM if there isn't enough memory to allocate the descriptor
 + *       - -ENODEV if DECO0 couldn't be acquired
 + *       - -EAGAIN if an error occurred when executing the descriptor
 + *          f.i. there was a RNG hardware error due to not "good enough"
 + *          entropy being aquired.
 + */
 +static int instantiate_rng(struct device *ctrldev, int state_handle_mask,
 +                         int gen_sk)
 +{
 +      struct caam_drv_private *ctrlpriv = dev_get_drvdata(ctrldev);
 +      struct caam_full __iomem *topregs;
 +      struct rng4tst __iomem *r4tst;
 +      u32 *desc, status, rdsta_val;
 +      int ret = 0, sh_idx;
 +
 +      topregs = (struct caam_full __iomem *)ctrlpriv->ctrl;
 +      r4tst = &topregs->ctrl.r4tst[0];
 +
 +      desc = kmalloc(CAAM_CMD_SZ * 7, GFP_KERNEL);
 +      if (!desc)
 +              return -ENOMEM;
 +
 +      for (sh_idx = 0; sh_idx < RNG4_MAX_HANDLES; sh_idx++) {
 +              /*
 +               * If the corresponding bit is set, this state handle
 +               * was initialized by somebody else, so it's left alone.
 +               */
 +              if ((1 << sh_idx) & state_handle_mask)
 +                      continue;
 +
 +              /* Create the descriptor for instantiating RNG State Handle */
 +              build_instantiation_desc(desc, sh_idx, gen_sk);
 +
 +              /* Try to run it through DECO0 */
 +              ret = run_descriptor_deco0(ctrldev, desc, &status);
 +
 +              /*
 +               * If ret is not 0, or descriptor status is not 0, then
 +               * something went wrong. No need to try the next state
 +               * handle (if available), bail out here.
 +               * Also, if for some reason, the State Handle didn't get
 +               * instantiated although the descriptor has finished
 +               * without any error (HW optimizations for later
 +               * CAAM eras), then try again.
 +               */
 +              rdsta_val =
 +                      rd_reg32(&topregs->ctrl.r4tst[0].rdsta) & RDSTA_IFMASK;
 +              if (status || !(rdsta_val & (1 << sh_idx)))
 +                      ret = -EAGAIN;
 +              if (ret)
 +                      break;
 +
 +              dev_info(ctrldev, "Instantiated RNG4 SH%d\n", sh_idx);
 +              /* Clear the contents before recreating the descriptor */
 +              memset(desc, 0x00, CAAM_CMD_SZ * 7);
 +      }
 +
 +      kfree(desc);
 +
 +      return ret;
 +}
 +
 +/*
 + * deinstantiate_rng - builds and executes a descriptor on DECO0,
 + *                   which deinitializes the RNG block.
 + * @ctrldev - pointer to device
 + * @state_handle_mask - bitmask containing the instantiation status
 + *                    for the RNG4 state handles which exist in
 + *                    the RNG4 block: 1 if it's been instantiated
 + *
 + * Return: - 0 if no error occurred
 + *       - -ENOMEM if there isn't enough memory to allocate the descriptor
 + *       - -ENODEV if DECO0 couldn't be acquired
 + *       - -EAGAIN if an error occurred when executing the descriptor
 + */
 +static int deinstantiate_rng(struct device *ctrldev, int state_handle_mask)
 +{
 +      u32 *desc, status;
 +      int sh_idx, ret = 0;
 +
 +      desc = kmalloc(CAAM_CMD_SZ * 3, GFP_KERNEL);
 +      if (!desc)
 +              return -ENOMEM;
 +
 +      for (sh_idx = 0; sh_idx < RNG4_MAX_HANDLES; sh_idx++) {
 +              /*
 +               * If the corresponding bit is set, then it means the state
 +               * handle was initialized by us, and thus it needs to be
 +               * deintialized as well
 +               */
 +              if ((1 << sh_idx) & state_handle_mask) {
 +                      /*
 +                       * Create the descriptor for deinstantating this state
 +                       * handle
 +                       */
 +                      build_deinstantiation_desc(desc, sh_idx);
 +
 +                      /* Try to run it through DECO0 */
 +                      ret = run_descriptor_deco0(ctrldev, desc, &status);
 +
 +                      if (ret || status) {
 +                              dev_err(ctrldev,
 +                                      "Failed to deinstantiate RNG4 SH%d\n",
 +                                      sh_idx);
 +                              break;
 +                      }
 +                      dev_info(ctrldev, "Deinstantiated RNG4 SH%d\n", sh_idx);
 +              }
 +      }
 +
        kfree(desc);
 +
 +      return ret;
 +}
 +
 +static int caam_remove(struct platform_device *pdev)
 +{
 +      struct device *ctrldev;
 +      struct caam_drv_private *ctrlpriv;
 +      struct caam_drv_private_jr *jrpriv;
 +      struct caam_full __iomem *topregs;
 +      int ring, ret = 0;
 +
 +      ctrldev = &pdev->dev;
 +      ctrlpriv = dev_get_drvdata(ctrldev);
 +      topregs = (struct caam_full __iomem *)ctrlpriv->ctrl;
 +
 +      /* shut down JobRs */
 +      for (ring = 0; ring < ctrlpriv->total_jobrs; ring++) {
 +              ret |= caam_jr_shutdown(ctrlpriv->jrdev[ring]);
 +              jrpriv = dev_get_drvdata(ctrlpriv->jrdev[ring]);
 +              irq_dispose_mapping(jrpriv->irq);
 +      }
 +
 +      /* De-initialize RNG state handles initialized by this driver. */
 +      if (ctrlpriv->rng4_sh_init)
 +              deinstantiate_rng(ctrldev, ctrlpriv->rng4_sh_init);
 +
 +      /* Shut down debug views */
 +#ifdef CONFIG_DEBUG_FS
 +      debugfs_remove_recursive(ctrlpriv->dfs_root);
 +#endif
 +
 +      /* Unmap controller region */
 +      iounmap(&topregs->ctrl);
 +
 +      kfree(ctrlpriv->jrdev);
 +      kfree(ctrlpriv);
 +
        return ret;
  }
  
  /*
 - * By default, the TRNG runs for 200 clocks per sample;
 - * 1600 clocks per sample generates better entropy.
 + * kick_trng - sets the various parameters for enabling the initialization
 + *           of the RNG4 block in CAAM
 + * @pdev - pointer to the platform device
 + * @ent_delay - Defines the length (in system clocks) of each entropy sample.
   */
 -static void kick_trng(struct platform_device *pdev)
 +static void kick_trng(struct platform_device *pdev, int ent_delay)
  {
        struct device *ctrldev = &pdev->dev;
        struct caam_drv_private *ctrlpriv = dev_get_drvdata(ctrldev);
  
        /* put RNG4 into program mode */
        setbits32(&r4tst->rtmctl, RTMCTL_PRGM);
 -      /* 1600 clocks per sample */
 +
 +      /*
 +       * Performance-wise, it does not make sense to
 +       * set the delay to a value that is lower
 +       * than the last one that worked (i.e. the state handles
 +       * were instantiated properly. Thus, instead of wasting
 +       * time trying to set the values controlling the sample
 +       * frequency, the function simply returns.
 +       */
 +      val = (rd_reg32(&r4tst->rtsdctl) & RTSDCTL_ENT_DLY_MASK)
 +            >> RTSDCTL_ENT_DLY_SHIFT;
 +      if (ent_delay <= val) {
 +              /* put RNG4 into run mode */
 +              clrbits32(&r4tst->rtmctl, RTMCTL_PRGM);
 +              return;
 +      }
 +
        val = rd_reg32(&r4tst->rtsdctl);
 -      val = (val & ~RTSDCTL_ENT_DLY_MASK) | (1600 << RTSDCTL_ENT_DLY_SHIFT);
 +      val = (val & ~RTSDCTL_ENT_DLY_MASK) |
 +            (ent_delay << RTSDCTL_ENT_DLY_SHIFT);
        wr_reg32(&r4tst->rtsdctl, val);
 -      /* min. freq. count */
 -      wr_reg32(&r4tst->rtfrqmin, 400);
 -      /* max. freq. count */
 -      wr_reg32(&r4tst->rtfrqmax, 6400);
 +      /* min. freq. count, equal to 1/4 of the entropy sample length */
 +      wr_reg32(&r4tst->rtfrqmin, ent_delay >> 2);
 +      /* max. freq. count, equal to 8 times the entropy sample length */
 +      wr_reg32(&r4tst->rtfrqmax, ent_delay << 3);
        /* put RNG4 into run mode */
        clrbits32(&r4tst->rtmctl, RTMCTL_PRGM);
  }
@@@ -385,7 -193,7 +388,7 @@@ EXPORT_SYMBOL(caam_get_era)
  /* Probe routine for CAAM top (controller) level */
  static int caam_probe(struct platform_device *pdev)
  {
 -      int ret, ring, rspec;
 +      int ret, ring, rspec, gen_sk, ent_delay = RTSDCTL_ENT_DLY_MIN;
        u64 caam_id;
        struct device *dev;
        struct device_node *nprop, *np;
  
        /*
         * If SEC has RNG version >= 4 and RNG state handle has not been
 -       * already instantiated ,do RNG instantiation
 +       * already instantiateddo RNG instantiation
         */
 -      if ((cha_vid & CHA_ID_RNG_MASK) >> CHA_ID_RNG_SHIFT >= 4 &&
 -          !(rd_reg32(&topregs->ctrl.r4tst[0].rdsta) & RDSTA_IF0)) {
 -              kick_trng(pdev);
 -              ret = instantiate_rng(dev);
 +      if ((cha_vid & CHA_ID_RNG_MASK) >> CHA_ID_RNG_SHIFT >= 4) {
 +              ctrlpriv->rng4_sh_init =
 +                      rd_reg32(&topregs->ctrl.r4tst[0].rdsta);
 +              /*
 +               * If the secure keys (TDKEK, JDKEK, TDSK), were already
 +               * generated, signal this to the function that is instantiating
 +               * the state handles. An error would occur if RNG4 attempts
 +               * to regenerate these keys before the next POR.
 +               */
 +              gen_sk = ctrlpriv->rng4_sh_init & RDSTA_SKVN ? 0 : 1;
 +              ctrlpriv->rng4_sh_init &= RDSTA_IFMASK;
 +              do {
 +                      int inst_handles =
 +                              rd_reg32(&topregs->ctrl.r4tst[0].rdsta) &
 +                                                              RDSTA_IFMASK;
 +                      /*
 +                       * If either SH were instantiated by somebody else
 +                       * (e.g. u-boot) then it is assumed that the entropy
 +                       * parameters are properly set and thus the function
 +                       * setting these (kick_trng(...)) is skipped.
 +                       * Also, if a handle was instantiated, do not change
 +                       * the TRNG parameters.
 +                       */
 +                      if (!(ctrlpriv->rng4_sh_init || inst_handles)) {
 +                              kick_trng(pdev, ent_delay);
 +                              ent_delay += 400;
 +                      }
 +                      /*
 +                       * if instantiate_rng(...) fails, the loop will rerun
 +                       * and the kick_trng(...) function will modfiy the
 +                       * upper and lower limits of the entropy sampling
 +                       * interval, leading to a sucessful initialization of
 +                       * the RNG.
 +                       */
 +                      ret = instantiate_rng(dev, inst_handles,
 +                                            gen_sk);
 +              } while ((ret == -EAGAIN) && (ent_delay < RTSDCTL_ENT_DLY_MAX));
                if (ret) {
 +                      dev_err(dev, "failed to instantiate RNG");
                        caam_remove(pdev);
                        return ret;
                }
 +              /*
 +               * Set handles init'ed by this module as the complement of the
 +               * already initialized ones
 +               */
 +              ctrlpriv->rng4_sh_init = ~ctrlpriv->rng4_sh_init & RDSTA_IFMASK;
  
                /* Enable RDB bit so that RNG works faster */
                setbits32(&topregs->ctrl.scfgr, SCFGR_RDBENABLE);
diff --combined drivers/crypto/talitos.c
index f6f7c681073e8b9132afa81c70a7af58cf3f8360,6cd0e603858321dd678b45ad74dda8f6746fba97..905de4427e7c4d1630604db45ffa2ba158983918
@@@ -32,6 -32,8 +32,8 @@@
  #include <linux/interrupt.h>
  #include <linux/crypto.h>
  #include <linux/hw_random.h>
+ #include <linux/of_address.h>
+ #include <linux/of_irq.h>
  #include <linux/of_platform.h>
  #include <linux/dma-mapping.h>
  #include <linux/io.h>
@@@ -671,20 -673,39 +673,20 @@@ static int aead_setkey(struct crypto_ae
                       const u8 *key, unsigned int keylen)
  {
        struct talitos_ctx *ctx = crypto_aead_ctx(authenc);
 -      struct rtattr *rta = (void *)key;
 -      struct crypto_authenc_key_param *param;
 -      unsigned int authkeylen;
 -      unsigned int enckeylen;
 -
 -      if (!RTA_OK(rta, keylen))
 -              goto badkey;
 -
 -      if (rta->rta_type != CRYPTO_AUTHENC_KEYA_PARAM)
 -              goto badkey;
 +      struct crypto_authenc_keys keys;
  
 -      if (RTA_PAYLOAD(rta) < sizeof(*param))
 +      if (crypto_authenc_extractkeys(&keys, key, keylen) != 0)
                goto badkey;
  
 -      param = RTA_DATA(rta);
 -      enckeylen = be32_to_cpu(param->enckeylen);
 -
 -      key += RTA_ALIGN(rta->rta_len);
 -      keylen -= RTA_ALIGN(rta->rta_len);
 -
 -      if (keylen < enckeylen)
 -              goto badkey;
 -
 -      authkeylen = keylen - enckeylen;
 -
 -      if (keylen > TALITOS_MAX_KEY_SIZE)
 +      if (keys.authkeylen + keys.enckeylen > TALITOS_MAX_KEY_SIZE)
                goto badkey;
  
 -      memcpy(&ctx->key, key, keylen);
 +      memcpy(ctx->key, keys.authkey, keys.authkeylen);
 +      memcpy(&ctx->key[keys.authkeylen], keys.enckey, keys.enckeylen);
  
 -      ctx->keylen = keylen;
 -      ctx->enckeylen = enckeylen;
 -      ctx->authkeylen = authkeylen;
 +      ctx->keylen = keys.authkeylen + keys.enckeylen;
 +      ctx->enckeylen = keys.enckeylen;
 +      ctx->authkeylen = keys.authkeylen;
  
        return 0;
  
index c6ef9f1c7a825f718a901139f4f56bc1c36d9e1d,e59c8860f472ac013ea9d550fdae011c39e0ad43..c966fc7474ced5fc8423b9440340f1d9b5072bbc
@@@ -28,6 -28,7 +28,7 @@@
  #include <linux/kernel.h>
  #include <linux/string.h>
  #include <linux/ioport.h>
+ #include <linux/of_address.h>
  #include <linux/of_platform.h>
  #include <linux/platform_device.h>
  #include <linux/slab.h>
@@@ -650,6 -651,8 +651,6 @@@ static int fsl_elbc_chip_init_tail(stru
                chip->page_shift);
        dev_dbg(priv->dev, "fsl_elbc_init: nand->phys_erase_shift = %d\n",
                chip->phys_erase_shift);
 -      dev_dbg(priv->dev, "fsl_elbc_init: nand->ecclayout = %p\n",
 -              chip->ecclayout);
        dev_dbg(priv->dev, "fsl_elbc_init: nand->ecc.mode = %d\n",
                chip->ecc.mode);
        dev_dbg(priv->dev, "fsl_elbc_init: nand->ecc.steps = %d\n",
index c96e1e0943f56d1a852f043d8243fb515ec3a371,2730c78d2bf821f57745b393605dfb001db3f6dc..43355779cff583975721e5c7bd7770bc055aa1c3
@@@ -24,6 -24,7 +24,7 @@@
  #include <linux/types.h>
  #include <linux/init.h>
  #include <linux/kernel.h>
+ #include <linux/of_address.h>
  #include <linux/slab.h>
  #include <linux/mtd/mtd.h>
  #include <linux/mtd/nand.h>
@@@ -135,69 -136,6 +136,69 @@@ static struct nand_ecclayout oob_4096_e
        .oobfree = { {2, 6}, {136, 82} },
  };
  
 +/* 8192-byte page size with 4-bit ECC */
 +static struct nand_ecclayout oob_8192_ecc4 = {
 +      .eccbytes = 128,
 +      .eccpos = {
 +              8, 9, 10, 11, 12, 13, 14, 15,
 +              16, 17, 18, 19, 20, 21, 22, 23,
 +              24, 25, 26, 27, 28, 29, 30, 31,
 +              32, 33, 34, 35, 36, 37, 38, 39,
 +              40, 41, 42, 43, 44, 45, 46, 47,
 +              48, 49, 50, 51, 52, 53, 54, 55,
 +              56, 57, 58, 59, 60, 61, 62, 63,
 +              64, 65, 66, 67, 68, 69, 70, 71,
 +              72, 73, 74, 75, 76, 77, 78, 79,
 +              80, 81, 82, 83, 84, 85, 86, 87,
 +              88, 89, 90, 91, 92, 93, 94, 95,
 +              96, 97, 98, 99, 100, 101, 102, 103,
 +              104, 105, 106, 107, 108, 109, 110, 111,
 +              112, 113, 114, 115, 116, 117, 118, 119,
 +              120, 121, 122, 123, 124, 125, 126, 127,
 +              128, 129, 130, 131, 132, 133, 134, 135,
 +      },
 +      .oobfree = { {2, 6}, {136, 208} },
 +};
 +
 +/* 8192-byte page size with 8-bit ECC -- requires 218-byte OOB */
 +static struct nand_ecclayout oob_8192_ecc8 = {
 +      .eccbytes = 256,
 +      .eccpos = {
 +              8, 9, 10, 11, 12, 13, 14, 15,
 +              16, 17, 18, 19, 20, 21, 22, 23,
 +              24, 25, 26, 27, 28, 29, 30, 31,
 +              32, 33, 34, 35, 36, 37, 38, 39,
 +              40, 41, 42, 43, 44, 45, 46, 47,
 +              48, 49, 50, 51, 52, 53, 54, 55,
 +              56, 57, 58, 59, 60, 61, 62, 63,
 +              64, 65, 66, 67, 68, 69, 70, 71,
 +              72, 73, 74, 75, 76, 77, 78, 79,
 +              80, 81, 82, 83, 84, 85, 86, 87,
 +              88, 89, 90, 91, 92, 93, 94, 95,
 +              96, 97, 98, 99, 100, 101, 102, 103,
 +              104, 105, 106, 107, 108, 109, 110, 111,
 +              112, 113, 114, 115, 116, 117, 118, 119,
 +              120, 121, 122, 123, 124, 125, 126, 127,
 +              128, 129, 130, 131, 132, 133, 134, 135,
 +              136, 137, 138, 139, 140, 141, 142, 143,
 +              144, 145, 146, 147, 148, 149, 150, 151,
 +              152, 153, 154, 155, 156, 157, 158, 159,
 +              160, 161, 162, 163, 164, 165, 166, 167,
 +              168, 169, 170, 171, 172, 173, 174, 175,
 +              176, 177, 178, 179, 180, 181, 182, 183,
 +              184, 185, 186, 187, 188, 189, 190, 191,
 +              192, 193, 194, 195, 196, 197, 198, 199,
 +              200, 201, 202, 203, 204, 205, 206, 207,
 +              208, 209, 210, 211, 212, 213, 214, 215,
 +              216, 217, 218, 219, 220, 221, 222, 223,
 +              224, 225, 226, 227, 228, 229, 230, 231,
 +              232, 233, 234, 235, 236, 237, 238, 239,
 +              240, 241, 242, 243, 244, 245, 246, 247,
 +              248, 249, 250, 251, 252, 253, 254, 255,
 +              256, 257, 258, 259, 260, 261, 262, 263,
 +      },
 +      .oobfree = { {2, 6}, {264, 80} },
 +};
  
  /*
   * Generic flash bbt descriptors
@@@ -504,29 -442,20 +505,29 @@@ static void fsl_ifc_cmdfunc(struct mtd_
                if (mtd->writesize > 512) {
                        nand_fcr0 =
                                (NAND_CMD_SEQIN << IFC_NAND_FCR0_CMD0_SHIFT) |
 -                              (NAND_CMD_PAGEPROG << IFC_NAND_FCR0_CMD1_SHIFT);
 +                              (NAND_CMD_STATUS << IFC_NAND_FCR0_CMD1_SHIFT) |
 +                              (NAND_CMD_PAGEPROG << IFC_NAND_FCR0_CMD2_SHIFT);
  
                        iowrite32be(
 -                              (IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) |
 -                              (IFC_FIR_OP_CA0 << IFC_NAND_FIR0_OP1_SHIFT) |
 -                              (IFC_FIR_OP_RA0 << IFC_NAND_FIR0_OP2_SHIFT) |
 -                              (IFC_FIR_OP_WBCD << IFC_NAND_FIR0_OP3_SHIFT) |
 -                              (IFC_FIR_OP_CW1 << IFC_NAND_FIR0_OP4_SHIFT),
 -                              &ifc->ifc_nand.nand_fir0);
 +                               (IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) |
 +                               (IFC_FIR_OP_CA0 << IFC_NAND_FIR0_OP1_SHIFT) |
 +                               (IFC_FIR_OP_RA0 << IFC_NAND_FIR0_OP2_SHIFT) |
 +                               (IFC_FIR_OP_WBCD  << IFC_NAND_FIR0_OP3_SHIFT) |
 +                               (IFC_FIR_OP_CMD2 << IFC_NAND_FIR0_OP4_SHIFT),
 +                               &ifc->ifc_nand.nand_fir0);
 +                      iowrite32be(
 +                               (IFC_FIR_OP_CW1 << IFC_NAND_FIR1_OP5_SHIFT) |
 +                               (IFC_FIR_OP_RDSTAT <<
 +                                      IFC_NAND_FIR1_OP6_SHIFT) |
 +                               (IFC_FIR_OP_NOP << IFC_NAND_FIR1_OP7_SHIFT),
 +                               &ifc->ifc_nand.nand_fir1);
                } else {
                        nand_fcr0 = ((NAND_CMD_PAGEPROG <<
                                        IFC_NAND_FCR0_CMD1_SHIFT) |
                                    (NAND_CMD_SEQIN <<
 -                                      IFC_NAND_FCR0_CMD2_SHIFT));
 +                                      IFC_NAND_FCR0_CMD2_SHIFT) |
 +                                  (NAND_CMD_STATUS <<
 +                                      IFC_NAND_FCR0_CMD3_SHIFT));
  
                        iowrite32be(
                                (IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) |
                                (IFC_FIR_OP_RA0 << IFC_NAND_FIR0_OP3_SHIFT) |
                                (IFC_FIR_OP_WBCD << IFC_NAND_FIR0_OP4_SHIFT),
                                &ifc->ifc_nand.nand_fir0);
 -                      iowrite32be(IFC_FIR_OP_CW1 << IFC_NAND_FIR1_OP5_SHIFT,
 -                                  &ifc->ifc_nand.nand_fir1);
 +                      iowrite32be(
 +                               (IFC_FIR_OP_CMD1 << IFC_NAND_FIR1_OP5_SHIFT) |
 +                               (IFC_FIR_OP_CW3 << IFC_NAND_FIR1_OP6_SHIFT) |
 +                               (IFC_FIR_OP_RDSTAT <<
 +                                      IFC_NAND_FIR1_OP7_SHIFT) |
 +                               (IFC_FIR_OP_NOP << IFC_NAND_FIR1_OP8_SHIFT),
 +                                &ifc->ifc_nand.nand_fir1);
  
                        if (column >= mtd->writesize)
                                nand_fcr0 |=
@@@ -795,6 -719,8 +796,6 @@@ static int fsl_ifc_chip_init_tail(struc
                                                        chip->page_shift);
        dev_dbg(priv->dev, "%s: nand->phys_erase_shift = %d\n", __func__,
                                                        chip->phys_erase_shift);
 -      dev_dbg(priv->dev, "%s: nand->ecclayout = %p\n", __func__,
 -                                                      chip->ecclayout);
        dev_dbg(priv->dev, "%s: nand->ecc.mode = %d\n", __func__,
                                                        chip->ecc.mode);
        dev_dbg(priv->dev, "%s: nand->ecc.steps = %d\n", __func__,
@@@ -947,25 -873,11 +948,25 @@@ static int fsl_ifc_chip_init(struct fsl
                } else {
                        layout = &oob_4096_ecc8;
                        chip->ecc.bytes = 16;
 +                      chip->ecc.strength = 8;
                }
  
                priv->bufnum_mask = 1;
                break;
  
 +      case CSOR_NAND_PGS_8K:
 +              if ((csor & CSOR_NAND_ECC_MODE_MASK) ==
 +                  CSOR_NAND_ECC_MODE_4) {
 +                      layout = &oob_8192_ecc4;
 +              } else {
 +                      layout = &oob_8192_ecc8;
 +                      chip->ecc.bytes = 16;
 +                      chip->ecc.strength = 8;
 +              }
 +
 +              priv->bufnum_mask = 0;
 +      break;
 +
        default:
                dev_err(priv->dev, "bad csor %#x: bad page size\n", csor);
                return -ENODEV;
@@@ -996,6 -908,7 +997,6 @@@ static int fsl_ifc_chip_remove(struct f
                iounmap(priv->vbase);
  
        ifc_nand_ctrl->chips[priv->bank] = NULL;
 -      dev_set_drvdata(priv->dev, NULL);
  
        return 0;
  }
@@@ -1170,7 -1083,25 +1171,7 @@@ static struct platform_driver fsl_ifc_n
        .remove      = fsl_ifc_nand_remove,
  };
  
 -static int __init fsl_ifc_nand_init(void)
 -{
 -      int ret;
 -
 -      ret = platform_driver_register(&fsl_ifc_nand_driver);
 -      if (ret)
 -              printk(KERN_ERR "fsl-ifc: Failed to register platform"
 -                              "driver\n");
 -
 -      return ret;
 -}
 -
 -static void __exit fsl_ifc_nand_exit(void)
 -{
 -      platform_driver_unregister(&fsl_ifc_nand_driver);
 -}
 -
 -module_init(fsl_ifc_nand_init);
 -module_exit(fsl_ifc_nand_exit);
 +module_platform_driver(fsl_ifc_nand_driver);
  
  MODULE_LICENSE("GPL");
  MODULE_AUTHOR("Freescale");
index d6d810cb97c79b80da7991f2ee423406b89853af,c49abb478e84090642942ef742558cbea6a54064..b14d7904a075e69779e4a2847dee1bedaba791d2
@@@ -78,6 -78,8 +78,8 @@@
  #include <linux/if_vlan.h>
  #include <linux/spinlock.h>
  #include <linux/mm.h>
+ #include <linux/of_address.h>
+ #include <linux/of_irq.h>
  #include <linux/of_mdio.h>
  #include <linux/of_platform.h>
  #include <linux/ip.h>
@@@ -88,7 -90,6 +90,7 @@@
  
  #include <asm/io.h>
  #include <asm/reg.h>
 +#include <asm/mpc85xx.h>
  #include <asm/irq.h>
  #include <asm/uaccess.h>
  #include <linux/module.h>
@@@ -940,8 -941,9 +942,8 @@@ static void gfar_init_filer_table(struc
        }
  }
  
 -static void gfar_detect_errata(struct gfar_private *priv)
 +static void __gfar_detect_errata_83xx(struct gfar_private *priv)
  {
 -      struct device *dev = &priv->ofdev->dev;
        unsigned int pvr = mfspr(SPRN_PVR);
        unsigned int svr = mfspr(SPRN_SVR);
        unsigned int mod = (svr >> 16) & 0xfff6; /* w/o E suffix */
            (pvr == 0x80861010 && (mod & 0xfff9) == 0x80c0))
                priv->errata |= GFAR_ERRATA_76;
  
 -      /* MPC8313 and MPC837x all rev */
 -      if ((pvr == 0x80850010 && mod == 0x80b0) ||
 -          (pvr == 0x80861010 && (mod & 0xfff9) == 0x80c0))
 -              priv->errata |= GFAR_ERRATA_A002;
 +      /* MPC8313 Rev < 2.0 */
 +      if (pvr == 0x80850010 && mod == 0x80b0 && rev < 0x0020)
 +              priv->errata |= GFAR_ERRATA_12;
 +}
 +
 +static void __gfar_detect_errata_85xx(struct gfar_private *priv)
 +{
 +      unsigned int svr = mfspr(SPRN_SVR);
  
 -      /* MPC8313 Rev < 2.0, MPC8548 rev 2.0 */
 -      if ((pvr == 0x80850010 && mod == 0x80b0 && rev < 0x0020) ||
 -          (pvr == 0x80210020 && mod == 0x8030 && rev == 0x0020))
 +      if ((SVR_SOC_VER(svr) == SVR_8548) && (SVR_REV(svr) == 0x20))
                priv->errata |= GFAR_ERRATA_12;
 +      if (((SVR_SOC_VER(svr) == SVR_P2020) && (SVR_REV(svr) < 0x20)) ||
 +          ((SVR_SOC_VER(svr) == SVR_P2010) && (SVR_REV(svr) < 0x20)))
 +              priv->errata |= GFAR_ERRATA_76; /* aka eTSEC 20 */
 +}
 +
 +static void gfar_detect_errata(struct gfar_private *priv)
 +{
 +      struct device *dev = &priv->ofdev->dev;
 +
 +      /* no plans to fix */
 +      priv->errata |= GFAR_ERRATA_A002;
 +
 +      if (pvr_version_is(PVR_VER_E500V1) || pvr_version_is(PVR_VER_E500V2))
 +              __gfar_detect_errata_85xx(priv);
 +      else /* non-mpc85xx parts, i.e. e300 core based */
 +              __gfar_detect_errata_83xx(priv);
  
        if (priv->errata)
                dev_info(dev, "enabled errata workarounds, flags: 0x%x\n",
@@@ -1617,7 -1601,7 +1619,7 @@@ static int __gfar_is_rx_idle(struct gfa
        /* Normaly TSEC should not hang on GRS commands, so we should
         * actually wait for IEVENT_GRSC flag.
         */
 -      if (likely(!gfar_has_errata(priv, GFAR_ERRATA_A002)))
 +      if (!gfar_has_errata(priv, GFAR_ERRATA_A002))
                return 0;
  
        /* Read the eTSEC register at offset 0xD1C. If bits 7-14 are
@@@ -2918,7 -2902,7 +2920,7 @@@ static int gfar_poll(struct napi_struc
        struct gfar_priv_rx_q *rx_queue = NULL;
        int work_done = 0, work_done_per_q = 0;
        int i, budget_per_q = 0;
 -      int has_tx_work;
 +      int has_tx_work = 0;
        unsigned long rstat_rxf;
        int num_act_queues;
  
        if (num_act_queues)
                budget_per_q = budget/num_act_queues;
  
 -      while (1) {
 -              has_tx_work = 0;
 -              for_each_set_bit(i, &gfargrp->tx_bit_map, priv->num_tx_queues) {
 -                      tx_queue = priv->tx_queue[i];
 -                      /* run Tx cleanup to completion */
 -                      if (tx_queue->tx_skbuff[tx_queue->skb_dirtytx]) {
 -                              gfar_clean_tx_ring(tx_queue);
 -                              has_tx_work = 1;
 -                      }
 +      for_each_set_bit(i, &gfargrp->tx_bit_map, priv->num_tx_queues) {
 +              tx_queue = priv->tx_queue[i];
 +              /* run Tx cleanup to completion */
 +              if (tx_queue->tx_skbuff[tx_queue->skb_dirtytx]) {
 +                      gfar_clean_tx_ring(tx_queue);
 +                      has_tx_work = 1;
                }
 +      }
  
 -              for_each_set_bit(i, &gfargrp->rx_bit_map, priv->num_rx_queues) {
 -                      /* skip queue if not active */
 -                      if (!(rstat_rxf & (RSTAT_CLEAR_RXF0 >> i)))
 -                              continue;
 -
 -                      rx_queue = priv->rx_queue[i];
 -                      work_done_per_q =
 -                              gfar_clean_rx_ring(rx_queue, budget_per_q);
 -                      work_done += work_done_per_q;
 -
 -                      /* finished processing this queue */
 -                      if (work_done_per_q < budget_per_q) {
 -                              /* clear active queue hw indication */
 -                              gfar_write(&regs->rstat,
 -                                         RSTAT_CLEAR_RXF0 >> i);
 -                              rstat_rxf &= ~(RSTAT_CLEAR_RXF0 >> i);
 -                              num_act_queues--;
 -
 -                              if (!num_act_queues)
 -                                      break;
 -                              /* recompute budget per Rx queue */
 -                              budget_per_q =
 -                                      (budget - work_done) / num_act_queues;
 -                      }
 -              }
 +      for_each_set_bit(i, &gfargrp->rx_bit_map, priv->num_rx_queues) {
 +              /* skip queue if not active */
 +              if (!(rstat_rxf & (RSTAT_CLEAR_RXF0 >> i)))
 +                      continue;
  
 -              if (work_done >= budget)
 -                      break;
 +              rx_queue = priv->rx_queue[i];
 +              work_done_per_q =
 +                      gfar_clean_rx_ring(rx_queue, budget_per_q);
 +              work_done += work_done_per_q;
 +
 +              /* finished processing this queue */
 +              if (work_done_per_q < budget_per_q) {
 +                      /* clear active queue hw indication */
 +                      gfar_write(&regs->rstat,
 +                                 RSTAT_CLEAR_RXF0 >> i);
 +                      num_act_queues--;
 +
 +                      if (!num_act_queues)
 +                              break;
 +              }
 +      }
  
 -              if (!num_act_queues && !has_tx_work) {
 +      if (!num_act_queues && !has_tx_work) {
  
 -                      napi_complete(napi);
 +              napi_complete(napi);
  
 -                      /* Clear the halt bit in RSTAT */
 -                      gfar_write(&regs->rstat, gfargrp->rstat);
 +              /* Clear the halt bit in RSTAT */
 +              gfar_write(&regs->rstat, gfargrp->rstat);
  
 -                      gfar_write(&regs->imask, IMASK_DEFAULT);
 +              gfar_write(&regs->imask, IMASK_DEFAULT);
  
 -                      /* If we are coalescing interrupts, update the timer
 -                       * Otherwise, clear it
 -                       */
 -                      gfar_configure_coalescing(priv, gfargrp->rx_bit_map,
 -                                                gfargrp->tx_bit_map);
 -                      break;
 -              }
 +              /* If we are coalescing interrupts, update the timer
 +               * Otherwise, clear it
 +               */
 +              gfar_configure_coalescing(priv, gfargrp->rx_bit_map,
 +                                        gfargrp->tx_bit_map);
        }
  
        return work_done;
index d58a3dfc95c296086f3d729819e42bc758ef5f6f,64b329fecf3d9e7ab2484ae7e704914ba3f02bc6..5548b6d00c31fe6282f108aa48bdbf45fc0c5eba
@@@ -31,6 -31,8 +31,8 @@@
  #include <linux/mii.h>
  #include <linux/phy.h>
  #include <linux/workqueue.h>
+ #include <linux/of_address.h>
+ #include <linux/of_irq.h>
  #include <linux/of_mdio.h>
  #include <linux/of_net.h>
  #include <linux/of_platform.h>
@@@ -3899,7 -3901,7 +3901,7 @@@ static int ucc_geth_probe(struct platfo
  
        mac_addr = of_get_mac_address(np);
        if (mac_addr)
 -              memcpy(dev->dev_addr, mac_addr, 6);
 +              memcpy(dev->dev_addr, mac_addr, ETH_ALEN);
  
        ugeth->ug_info = ug_info;
        ugeth->dev = device;
index ef21a2e10180c516a5ee3935b15af5fb52b506ab,cdf2321f1f0f0dbb0f14ba8b745ab361055ebfe1..ae342fdb42c8e79853507007ad2ea6c8d3681fad
@@@ -39,6 -39,8 +39,8 @@@
  #include <linux/bitops.h>
  #include <linux/workqueue.h>
  #include <linux/of.h>
+ #include <linux/of_address.h>
+ #include <linux/of_irq.h>
  #include <linux/of_net.h>
  #include <linux/slab.h>
  
@@@ -2676,7 -2678,7 +2678,7 @@@ static int emac_init_config(struct emac
                       np->full_name);
                return -ENXIO;
        }
 -      memcpy(dev->ndev->dev_addr, p, 6);
 +      memcpy(dev->ndev->dev_addr, p, ETH_ALEN);
  
        /* IAHT and GAHT filter parameterization */
        if (emac_has_feature(dev, EMAC_FTR_EMAC4SYNC)) {
index 0029148077a9805a288a42a9d8207a97ce6e8133,22478d54f5bb7f362642886e2fed62289ebdb339..1f23641263232fce0255d237976cbf5470e22a6c
@@@ -36,6 -36,7 +36,7 @@@
  #include <linux/netdevice.h>
  #include <linux/of.h>
  #include <linux/of_device.h>
+ #include <linux/of_irq.h>
  #include <linux/of_mdio.h>
  #include <linux/of_platform.h>
  #include <linux/of_address.h>
@@@ -297,12 -298,6 +298,12 @@@ static int temac_dma_bd_init(struct net
                       lp->rx_bd_p + (sizeof(*lp->rx_bd_v) * (RX_BD_NUM - 1)));
        lp->dma_out(lp, TX_CURDESC_PTR, lp->tx_bd_p);
  
 +      /* Init descriptor indexes */
 +      lp->tx_bd_ci = 0;
 +      lp->tx_bd_next = 0;
 +      lp->tx_bd_tail = 0;
 +      lp->rx_bd_ci = 0;
 +
        return 0;
  
  out:
diff --combined drivers/of/address.c
index 71180b91bfbe7d9ef3167fe497cea72fb890f515,556a7fb6ead3ae0dc49ebe42ae743b23752e4787..27224c0d80a6dd170c53f99c097d851f32395b26
@@@ -489,7 -489,7 +489,7 @@@ static u64 __of_translate_address(struc
        int na, ns, pna, pns;
        u64 result = OF_BAD_ADDR;
  
 -      pr_debug("OF: ** translation for device %s **\n", dev->full_name);
 +      pr_debug("OF: ** translation for device %s **\n", of_node_full_name(dev));
  
        /* Increase refcount at current level */
        of_node_get(dev);
        bus->count_cells(dev, &na, &ns);
        if (!OF_CHECK_COUNTS(na, ns)) {
                printk(KERN_ERR "prom_parse: Bad cell count for %s\n",
 -                     dev->full_name);
 +                     of_node_full_name(dev));
                goto bail;
        }
        memcpy(addr, in_addr, na * 4);
  
        pr_debug("OF: bus is %s (na=%d, ns=%d) on %s\n",
 -          bus->name, na, ns, parent->full_name);
 +          bus->name, na, ns, of_node_full_name(parent));
        of_dump_addr("OF: translating address:", addr, na);
  
        /* Translate */
@@@ -626,6 -626,14 +626,14 @@@ const __be32 *of_get_address(struct dev
  }
  EXPORT_SYMBOL(of_get_address);
  
+ unsigned long __weak pci_address_to_pio(phys_addr_t address)
+ {
+       if (address > IO_SPACE_LIMIT)
+               return (unsigned long)-1;
+       return (unsigned long) address;
+ }
  static int __of_address_to_resource(struct device_node *dev,
                const __be32 *addrp, u64 size, unsigned int flags,
                const char *name, struct resource *r)
diff --combined drivers/of/base.c
index 3ae106d8979149e57fb1bce2cab413191014da39,ced4c06d79b36d5c95b27b03e284843033da713a..a96f8503afcddfdd452e4902b715253141086a3f
@@@ -74,6 -74,13 +74,13 @@@ int of_n_size_cells(struct device_node 
  }
  EXPORT_SYMBOL(of_n_size_cells);
  
+ #ifdef CONFIG_NUMA
+ int __weak of_node_to_nid(struct device_node *np)
+ {
+       return numa_node_id();
+ }
+ #endif
  #if defined(CONFIG_OF_DYNAMIC)
  /**
   *    of_node_get - Increment refcount of a node
@@@ -265,9 -272,9 +272,9 @@@ static bool __of_find_n_match_cpu_prope
  
        ac = of_n_addr_cells(cpun);
        cell = of_get_property(cpun, prop_name, &prop_len);
 -      if (!cell)
 +      if (!cell || !ac)
                return false;
 -      prop_len /= sizeof(*cell);
 +      prop_len /= sizeof(*cell) * ac;
        for (tid = 0; tid < prop_len; tid++) {
                hwid = of_read_number(cell, ac);
                if (arch_match_cpu_phys_id(cpu, hwid)) {
        return false;
  }
  
 +/*
 + * arch_find_n_match_cpu_physical_id - See if the given device node is
 + * for the cpu corresponding to logical cpu 'cpu'.  Return true if so,
 + * else false.  If 'thread' is non-NULL, the local thread number within the
 + * core is returned in it.
 + */
 +bool __weak arch_find_n_match_cpu_physical_id(struct device_node *cpun,
 +                                            int cpu, unsigned int *thread)
 +{
 +      /* Check for non-standard "ibm,ppc-interrupt-server#s" property
 +       * for thread ids on PowerPC. If it doesn't exist fallback to
 +       * standard "reg" property.
 +       */
 +      if (IS_ENABLED(CONFIG_PPC) &&
 +          __of_find_n_match_cpu_property(cpun,
 +                                         "ibm,ppc-interrupt-server#s",
 +                                         cpu, thread))
 +              return true;
 +
 +      if (__of_find_n_match_cpu_property(cpun, "reg", cpu, thread))
 +              return true;
 +
 +      return false;
 +}
 +
  /**
   * of_get_cpu_node - Get device node associated with the given logical CPU
   *
   */
  struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
  {
 -      struct device_node *cpun, *cpus;
 +      struct device_node *cpun;
  
 -      cpus = of_find_node_by_path("/cpus");
 -      if (!cpus) {
 -              pr_warn("Missing cpus node, bailing out\n");
 -              return NULL;
 -      }
 -
 -      for_each_child_of_node(cpus, cpun) {
 -              if (of_node_cmp(cpun->type, "cpu"))
 -                      continue;
 -              /* Check for non-standard "ibm,ppc-interrupt-server#s" property
 -               * for thread ids on PowerPC. If it doesn't exist fallback to
 -               * standard "reg" property.
 -               */
 -              if (IS_ENABLED(CONFIG_PPC) &&
 -                      __of_find_n_match_cpu_property(cpun,
 -                              "ibm,ppc-interrupt-server#s", cpu, thread))
 -                      return cpun;
 -              if (__of_find_n_match_cpu_property(cpun, "reg", cpu, thread))
 +      for_each_node_by_type(cpun, "cpu") {
 +              if (arch_find_n_match_cpu_physical_id(cpun, cpu, thread))
                        return cpun;
        }
        return NULL;
diff --combined drivers/of/fdt.c
index a4fa9ad31b8f7cfb62f45abf47ada0649d87b867,5c479104fc677a2169c3f49b02ebde8435365fdd..2fa024b97c4350c680e384c645dc17d0fc5dc177
@@@ -18,6 -18,7 +18,6 @@@
  #include <linux/string.h>
  #include <linux/errno.h>
  #include <linux/slab.h>
 -#include <linux/random.h>
  
  #include <asm/setup.h>  /* for COMMAND_LINE_SIZE */
  #ifdef CONFIG_PPC
@@@ -618,12 -619,72 +618,72 @@@ int __init of_scan_flat_dt_by_path(cons
                return ret;
  }
  
+ const char * __init of_flat_dt_get_machine_name(void)
+ {
+       const char *name;
+       unsigned long dt_root = of_get_flat_dt_root();
+       name = of_get_flat_dt_prop(dt_root, "model", NULL);
+       if (!name)
+               name = of_get_flat_dt_prop(dt_root, "compatible", NULL);
+       return name;
+ }
+ /**
+  * of_flat_dt_match_machine - Iterate match tables to find matching machine.
+  *
+  * @default_match: A machine specific ptr to return in case of no match.
+  * @get_next_compat: callback function to return next compatible match table.
+  *
+  * Iterate through machine match tables to find the best match for the machine
+  * compatible string in the FDT.
+  */
+ const void * __init of_flat_dt_match_machine(const void *default_match,
+               const void * (*get_next_compat)(const char * const**))
+ {
+       const void *data = NULL;
+       const void *best_data = default_match;
+       const char *const *compat;
+       unsigned long dt_root;
+       unsigned int best_score = ~1, score = 0;
+       dt_root = of_get_flat_dt_root();
+       while ((data = get_next_compat(&compat))) {
+               score = of_flat_dt_match(dt_root, compat);
+               if (score > 0 && score < best_score) {
+                       best_data = data;
+                       best_score = score;
+               }
+       }
+       if (!best_data) {
+               const char *prop;
+               long size;
+               pr_err("\n unrecognized device tree list:\n[ ");
+               prop = of_get_flat_dt_prop(dt_root, "compatible", &size);
+               if (prop) {
+                       while (size > 0) {
+                               printk("'%s' ", prop);
+                               size -= strlen(prop) + 1;
+                               prop += strlen(prop) + 1;
+                       }
+               }
+               printk("]\n\n");
+               return NULL;
+       }
+       pr_info("Machine model: %s\n", of_flat_dt_get_machine_name());
+       return best_data;
+ }
  #ifdef CONFIG_BLK_DEV_INITRD
  /**
   * early_init_dt_check_for_initrd - Decode initrd location from flat tree
   * @node: reference to node containing initrd location ('chosen')
   */
- void __init early_init_dt_check_for_initrd(unsigned long node)
static void __init early_init_dt_check_for_initrd(unsigned long node)
  {
        u64 start, end;
        unsigned long len;
                return;
        end = of_read_number(prop, len/4);
  
-       early_init_dt_setup_initrd_arch(start, end);
+       initrd_start = (unsigned long)__va(start);
+       initrd_end = (unsigned long)__va(end);
+       initrd_below_start_ok = 1;
        pr_debug("initrd_start=0x%llx  initrd_end=0x%llx\n",
                 (unsigned long long)start, (unsigned long long)end);
  }
  #else
- inline void early_init_dt_check_for_initrd(unsigned long node)
static inline void early_init_dt_check_for_initrd(unsigned long node)
  {
  }
  #endif /* CONFIG_BLK_DEV_INITRD */
@@@ -774,6 -838,25 +837,25 @@@ int __init early_init_dt_scan_chosen(un
  }
  
  #ifdef CONFIG_HAVE_MEMBLOCK
+ void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size)
+ {
+       const u64 phys_offset = __pa(PAGE_OFFSET);
+       base &= PAGE_MASK;
+       size &= PAGE_MASK;
+       if (base + size < phys_offset) {
+               pr_warning("Ignoring memory block 0x%llx - 0x%llx\n",
+                          base, base + size);
+               return;
+       }
+       if (base < phys_offset) {
+               pr_warning("Ignoring memory range 0x%llx - 0x%llx\n",
+                          base, phys_offset);
+               size -= phys_offset - base;
+               base = phys_offset;
+       }
+       memblock_add(base, size);
+ }
  /*
   * called from unflatten_device_tree() to bootstrap devicetree itself
   * Architectures can override this definition if memblock isn't used
@@@ -784,6 -867,32 +866,32 @@@ void * __init __weak early_init_dt_allo
  }
  #endif
  
+ bool __init early_init_dt_scan(void *params)
+ {
+       if (!params)
+               return false;
+       /* Setup flat device-tree pointer */
+       initial_boot_params = params;
+       /* check device tree validity */
+       if (be32_to_cpu(initial_boot_params->magic) != OF_DT_HEADER) {
+               initial_boot_params = NULL;
+               return false;
+       }
+       /* Retrieve various information from the /chosen node */
+       of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line);
+       /* Initialize {size,address}-cells info */
+       of_scan_flat_dt(early_init_dt_scan_root, NULL);
+       /* Setup memory, calling early_init_dt_add_memory_arch */
+       of_scan_flat_dt(early_init_dt_scan_memory, NULL);
+       return true;
+ }
  /**
   * unflatten_device_tree - create tree of device_nodes from flat blob
   *
@@@ -801,4 -910,39 +909,28 @@@ void __init unflatten_device_tree(void
        of_alias_scan(early_init_dt_alloc_memory_arch);
  }
  
+ /**
+  * unflatten_and_copy_device_tree - copy and create tree of device_nodes from flat blob
+  *
+  * Copies and unflattens the device-tree passed by the firmware, creating the
+  * tree of struct device_node. It also fills the "name" and "type"
+  * pointers of the nodes so the normal device-tree walking functions
+  * can be used. This should only be used when the FDT memory has not been
+  * reserved such is the case when the FDT is built-in to the kernel init
+  * section. If the FDT memory is reserved already then unflatten_device_tree
+  * should be used instead.
+  */
+ void __init unflatten_and_copy_device_tree(void)
+ {
+       int size = __be32_to_cpu(initial_boot_params->totalsize);
+       void *dt = early_init_dt_alloc_memory_arch(size,
+               __alignof__(struct boot_param_header));
+       if (dt) {
+               memcpy(dt, initial_boot_params, size);
+               initial_boot_params = dt;
+       }
+       unflatten_device_tree();
+ }
  #endif /* CONFIG_OF_EARLY_FLATTREE */
 -
 -/* Feed entire flattened device tree into the random pool */
 -static int __init add_fdt_randomness(void)
 -{
 -      if (initial_boot_params)
 -              add_device_randomness(initial_boot_params,
 -                              be32_to_cpu(initial_boot_params->totalsize));
 -
 -      return 0;
 -}
 -core_initcall(add_fdt_randomness);
index 6adf4e35816d76c1c7f120cd924420c4c8bf71a1,6148b1dae94caee71dbc81d9fa6b3672bd2c60e8..8dcc1432f1f51fba2505bad2c6d5ab6690182faf
@@@ -20,6 -20,7 +20,7 @@@
  #include <linux/errno.h>
  #include <linux/interrupt.h>
  #include <linux/of_address.h>
+ #include <linux/of_irq.h>
  #include <linux/of_platform.h>
  #include <linux/completion.h>
  #include <linux/io.h>
@@@ -522,10 -523,8 +523,10 @@@ static int mpc512x_psc_spi_do_probe(str
        psc_num = master->bus_num;
        snprintf(clk_name, sizeof(clk_name), "psc%d_mclk", psc_num);
        clk = devm_clk_get(dev, clk_name);
 -      if (IS_ERR(clk))
 +      if (IS_ERR(clk)) {
 +              ret = PTR_ERR(clk);
                goto free_irq;
 +      }
        ret = clk_prepare_enable(clk);
        if (ret)
                goto free_irq;
diff --combined sound/soc/fsl/fsl_dma.c
index f73c7eff8b237b0d7786cd71005789af12b8c0a3,d1b111e7fc07b550a242572bdbd8f5bb719a9165..fb9bb9eb5ca38f56d7359b6c57af772ee941675c
@@@ -21,6 -21,8 +21,8 @@@
  #include <linux/interrupt.h>
  #include <linux/delay.h>
  #include <linux/gfp.h>
+ #include <linux/of_address.h>
+ #include <linux/of_irq.h>
  #include <linux/of_platform.h>
  #include <linux/list.h>
  #include <linux/slab.h>
@@@ -298,11 -300,14 +300,11 @@@ static int fsl_dma_new(struct snd_soc_p
  {
        struct snd_card *card = rtd->card->snd_card;
        struct snd_pcm *pcm = rtd->pcm;
 -      static u64 fsl_dma_dmamask = DMA_BIT_MASK(36);
        int ret;
  
 -      if (!card->dev->dma_mask)
 -              card->dev->dma_mask = &fsl_dma_dmamask;
 -
 -      if (!card->dev->coherent_dma_mask)
 -              card->dev->coherent_dma_mask = fsl_dma_dmamask;
 +      ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(36));
 +      if (ret)
 +              return ret;
  
        /* Some codecs have separate DAIs for playback and capture, so we
         * should allocate a DMA buffer only for the streams that are valid.
index 8fcf2241674054a8d687ae94598a0b1beed26e8a,161e5055ce94f408f380929807bfb3a9dc21760c..71bf2f248cd47be5fb025baa6535296b49d75bbd
@@@ -10,6 -10,8 +10,8 @@@
  #include <linux/of_device.h>
  #include <linux/dma-mapping.h>
  #include <linux/slab.h>
+ #include <linux/of_address.h>
+ #include <linux/of_irq.h>
  #include <linux/of_platform.h>
  
  #include <sound/soc.h>
@@@ -299,6 -301,7 +301,6 @@@ static struct snd_pcm_ops psc_dma_ops 
        .hw_params      = psc_dma_hw_params,
  };
  
 -static u64 psc_dma_dmamask = DMA_BIT_MASK(32);
  static int psc_dma_new(struct snd_soc_pcm_runtime *rtd)
  {
        struct snd_card *card = rtd->card->snd_card;
        struct snd_pcm *pcm = rtd->pcm;
        struct psc_dma *psc_dma = snd_soc_dai_get_drvdata(rtd->cpu_dai);
        size_t size = psc_dma_hardware.buffer_bytes_max;
 -      int rc = 0;
 +      int rc;
  
        dev_dbg(rtd->platform->dev, "psc_dma_new(card=%p, dai=%p, pcm=%p)\n",
                card, dai, pcm);
  
 -      if (!card->dev->dma_mask)
 -              card->dev->dma_mask = &psc_dma_dmamask;
 -      if (!card->dev->coherent_dma_mask)
 -              card->dev->coherent_dma_mask = DMA_BIT_MASK(32);
 +      rc = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
 +      if (rc)
 +              return rc;
  
        if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) {
                rc = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->card->dev,