]> git.sur5r.net Git - u-boot/blobdiff - drivers/spi/soft_spi.c
arm: atmel: get rid of too many ifdeffery
[u-boot] / drivers / spi / soft_spi.c
index 25b589ad7c604dc280c33050c6db4119de1440b6..5d22351290b6337280434cca41e2dd3372c504d2 100644 (file)
@@ -5,23 +5,7 @@
  * Influenced by code from:
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -59,7 +43,7 @@ static inline struct soft_spi_slave *to_soft_spi(struct spi_slave *slave)
 void spi_init (void)
 {
 #ifdef SPI_INIT
-       volatile immap_t *immr = (immap_t *)CFG_IMMR;
+       volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
 
        SPI_INIT;
 #endif
@@ -73,12 +57,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
        if (!spi_cs_is_valid(bus, cs))
                return NULL;
 
-       ss = malloc(sizeof(struct soft_spi_slave));
+       ss = spi_alloc_slave(struct soft_spi_slave, bus, cs);
        if (!ss)
                return NULL;
 
-       ss->slave.bus = bus;
-       ss->slave.cs = cs;
        ss->mode = mode;
 
        /* TODO: Use max_hz to limit the SCK rate */
@@ -95,8 +77,8 @@ void spi_free_slave(struct spi_slave *slave)
 
 int spi_claim_bus(struct spi_slave *slave)
 {
-#ifdef CFG_IMMR
-       volatile immap_t *immr = (immap_t *)CFG_IMMR;
+#ifdef CONFIG_SYS_IMMR
+       volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
 #endif
        struct soft_spi_slave *ss = to_soft_spi(slave);
 
@@ -132,8 +114,8 @@ void spi_release_bus(struct spi_slave *slave)
 int  spi_xfer(struct spi_slave *slave, unsigned int bitlen,
                const void *dout, void *din, unsigned long flags)
 {
-#ifdef CFG_IMMR
-       volatile immap_t *immr = (immap_t *)CFG_IMMR;
+#ifdef CONFIG_SYS_IMMR
+       volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
 #endif
        struct soft_spi_slave *ss = to_soft_spi(slave);
        uchar           tmpdin  = 0;